Excerpt from: http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=7660&extra=page%3D1%26filter%3Dtypeid% 26typeid%3d36
1. Gzip Tool
Syntax: gzip [-d#] filename where # is a number 1-9, the default compression level is 6, only files can be compressed
gzip filename generation filename.gz source file disappears
GZIP-DV filename.gz Unzip, the compressed file disappears (-V shows the instruction execution process)
Zcat filename.gz Viewing the contents of a GZ compressed file
2. BZIP2 Compression Tool
Syntax: bzip2 [-DZ] filename
Compression, you can add "-Z" can also not add, can be compressed files bzip2 filename generated filename.bz2 source files disappear
Compression directory not supported
bzip2-d filename.bz2 compressed file disappears after decompression
You can use Bzcat to view the contents of bz2 files before compression
3. XZ
Usage with gzip and bzip2
XZ filename
Generate FILENAME.XZ
Compression directory not supported
xz-d FILENAME.XZ for decompression
Xzcat filename.xz View XZ Compressed file contents
4. zip and Unzip
Zip is a compression tool, unzip is the unzip tool
Compressed files: Zip filename.zip filename
Compression directory: Zip-r dir.zip dir/
Unzip Zip package: Unzip Filename.zip
Unzip-l Filename.zip lists the list of files in the zipped package
Unzip-d/tmp/filename.zip Unzip the package to the specified directory
5. Tar Packaging tool
You can package a directory or package files
Syntax: tar [-ZJXCVFPP] filename
Package: TAR-CVF Test.tar test where test is a file or directory
-C: To create a package,-V Visualization, compressed with "-F file name", meaning the compressed file name filename, decompression with "-F file name", if it is a combination of multiple parameters with "-F", please write "-F" to the last side.
-U: Add a new file in the package, such as Tar-u 1.TXT-VF Test.tar
View Package Contents: TAR-TF Test.tar
-T: View the files inside the tar package
Unpacking: TAR-XVF Test.tar
-X: Unpacking or decompressing
-C: Extract to the specified directory, such as Tar-c/tmp/-XVF Test.tar
Whether packaged or unpacked, the original file will not be deleted, but it will overwrite the existing file or directory.
Use gzip compression while packaging: TAR-CZVF 1.tar.gz 1 where 1 can be a file or a directory
-Z means that the package also uses GZIP compression
Unzip the. tar.gz Package: TAR-XZVF 1.tar.gz
Using bzip2 compression: TAR-CJVF 1.tar.bz2 1
-j means packaging uses bzip2 compression at the same time
Unzip. TAR.BZ2:TAR-XJVF 1.tar.bz2
Sometimes we see a file with a suffix called. Tar.xz, which is compressed with the XZ tool, and the method of decompression is:
TAR-JXVF file.tar.xz need to install XZ tool, yum install-y xz*
TAR-CJVF DIR.TAR.XZ dir///package compression range XZ format Compression package
Also use TAR-TF to view compressed packages: TAR-TF 1.tar.gz or TAR-TF 1.tar.bz2
--exclude can exclude certain files or directories while packaging
Tar--exclude 1.txt-czvf 1.tar.gz dir/
Exclude multiple files or directories: Tar--exclude 1.txt--exclude 123/-czvf 1.tar.gz dir/
Compression and packaging of Linux documents