Linux Day4

Delete, Copy, Move, Rename,  Compress , Creating archives

Removing Files

rm file : Remove file
rm -r dir : Remove the directory and its contents recursively
rm -f file : Force removla and never prompt for confirmation

Copying Files

cp source_file destination_file
cp src_file1 [src_fileN ...] dest_dir
cp -i : Run in interactive mode (오버라이딩 할 지 물어본다)
cp -r source_directory destination : Copy src_directory recursively to destination

Moving and Renaming Files

mv : Move or rename files and directories
mv source destination
mv -i source destination
  • firstdir라는게 없으면 dir이 firstdir되니까 rename하나보다

    mv dir firstdir
    
  • file1이 file2를 오버라이드 한다.

    mv file1 file2 
    

Sorting Options

-k F : Sort by Key. F is the field number.
-r : Sort in reverse order
-u : Sort unique

Creating a Collection of Files

  • Create, extract or list contents of a tar archive using pattern , if supplied.

    tar [-] c|x|t f tarfile [pattern]
    
    • options

      c : Create a tar archive.
      x : Extract files from the archive.
      t : Display the table of contents (list).
      v : Be verbose
      z : Use compression
      f file : Use this file
      

Compressing Files To Save Space

gzip : Compress files
gunzip : Uncompress files
gzcat : concatenates compressed files
zcat : Concatenates compressed files
  • tgz = tar.gz

Disk Usage

du : Estimates file usage
du -k : Display sizes in KB
du -h : Display sizes in human readable format

© 2018. All rights reserved.

Powered by Hydejack v8.5.2