Transferred from http://blog.csdn.net/yangjin_unique/article/details/7824852
Tar
Unpack: Tar xvf Filename.tar
Packing: Tar cvf filename.tar dirname
(Note: Tar is packed, not compressed.) )
———————————————
. gz
Decompression 1:gunzip filename.gz
Decompression 2:gzip-d filename.gz
Compression: gzip FileName
. tar.gz
Decompression: Tar zxvf FileName.tar.gz
Compression: Tar zcvf FileName.tar.gz dirname
———————————————
. bz2
Decompression 1:bzip2-d filename.bz2
Decompression 2:BUNZIP2 filename.bz2
Compression: Bzip2-z FileName
. tar.bz2
Decompression: Tar jxvf FileName.tar.bz2
Compression: Tar jcvf FileName.tar.bz2 dirname
———————————————
. BZ
Decompression 1:bzip2-d filename.bz
Decompression 2:BUNZIP2 filename.bz
. tar.bz
Decompression: Tar jxvf FileName.tar.bz
———————————————
. Z
Decompression: uncompress filename.z
Compression: Compress FileName
. Tar. Z
Decompression: Tar zxvf filename.tar.z
Compression: Tar zcvf filename.tar.z dirname
———————————————
. tgz
Decompression: Tar zxvf filename.tgz
. tar.tgz
Decompression: Tar zxvf FileName.tar.tgz
Compression: Tar zcvf FileName.tar.tgz FileName
———————————————
. zip
Decompression: Unzip Filename.zip
Compression: Zip Filename.zip dirname
———————————————
. rar
Decompression: rar a Filename.rar
Compression: RAR e Filename.rar
———————————————
. Lha
Decompression: Lha-e Filename.lha
Compression: Lha-a Filename.lha FileName
Zip
Zip may be the document compression format that is currently most used. Its greatest advantage is that it is used on different operating system platforms, such as Linux, Windows, and MacOS. The disadvantage is that the compression rate is not very high, and tar.gz and tar.gz2 do very well in the compression rate. Less gossip, let's get to the point:
We can compress a directory using the following commands:
# zip-r Archive_name.zip directory_to_compress
Here's what to do if you unzip a zip document:
# Unzip Archive_name.zip
TAR
Tar is a very extensive document packaging format used in Linux. Its advantage is that it consumes very little CPU and time to pack files, he is just a packaging tool, not responsible for compression. Here's how to package a directory:
# TAR-CVF Archive_name.tar directory_to_compress
How to unpack:
# TAR-XVF Archive_name.tar.gz
The above unpack command will unlock the document under the current directory. Of course, you can also use this command to pinch the path of the unpack:
# TAR-XVF Archive_name.tar-c/tmp/extract_here/
TAR. GZ
This format is the most compressed format I have ever used. It does not take up too much CPU during compression and can get a very desirable compression rate. Use the following format to compress a directory:
# TAR-ZCVF archive_name.tar.gz directory_to_compress
Decompression:
# TAR-ZXVF Archive_name.tar.gz
The above unpack command will unlock the document under the current directory. Of course, you can also use this command to pinch the path of the unpack:
# TAR-ZXVF Archive_name.tar.gz-c/tmp/extract_here/
TAR. BZ2
This compression format is the best in all the ways we mentioned. Of course, this means that it takes up more CPU and time than the previous way. This is how you use tar.bz2 for compression.
# TAR-JCVF archive_name.tar.bz2 directory_to_compress
The above unpack command will unlock the document under the current directory. Of course, you can also use this command to pinch the path of the unpack:
# TAR-JXVF Archive_name.tar.bz2-c/tmp/extract_here/