Linux File compression and Archive command

File compression and Archive command summary

compressed format: gz, bz2, xz, Z, zip Compression algorithm: the algorithm is different, the compression ratio will be different;

1.gzip

gzip: .gz 
  gzip /PATH/TO/SOMEFILE: gzip will delete the original file after the completion of the compression
  gzip -d: decompression
       -#: 1-9, specify the compression ratio, the default is 6;
gunzip:
  gunzip /PATH/TO/SOMEFILE.gz: delete the original file after decompression
  zcat /PATH/TO/SOMEFILE.gz:  without extracting the contents of the text file

2.bzip2

bzip2: .bz2
The compression tool, which has a greater compression ratio than the gzip, uses the format approximation
   bzip2 /PATH/TO/SOMEFILE 
       -d: decompression
       -#: 1-9, the default is 6;
       -k: compression to retain the original file
   bunzip2 /PATH/TO/SOMEFILE.bz2 : decompression
   bzcat /PATH/TO/SOMEFILE.gz:  without extracting the contents of the text file

3.xz

 xz: .xz
    xz /PATH/TO/SOMEFILE 
       -d: decompression
       -#: 1-9, the default is 6;
       -k: compression to retain the original file
     unxz /PATH/TO/SOMEFILE.bz2 : decompression
     xzcat /PATH/TO/SOMEFILE.gz:  without extracting the contents of the text file
zip: tools for both archive and compression
    zip FILENAME.zip FILE1 FILE2 ... : Do not delete the original file after compression
    unzip FILENAME.zip: decompression

4.archive

Archive: archive, the archive itself does not mean that the compression
tar: only file is archive and not compressed
     -c: create the archive
     -f FILE.tar : Use the file name, please note that you need to pick the file name immediately after f! Don't add parameter!
Such as the use of "tar -zcvfP tfile sfile" is the wrong way, to write " tar -zcvPf tfile sfile" is right! 
     -x: open the archive
     --xattrs:Extended attribute information for the file
     -t: not to open the file, directly to view the file

     -zcf: file and call gzip compression
     -zxf: calls gzip to extract and expand the archive

     -jcf: bzip2
     -jxf:

     -Jcf: xz
     -Jxf:

Pingbacks are closed.

Comments are closed.