Article Directory
1. gzip, gunzip
grammar:
gzip 文件名 #压缩文件
gunzip 文件名 #解压缩文件
gzip can compress files, directory can not be compressed. Use gzip command does not retain the original files after archiving.
If you want to compress directory how to do, then you should use the following command tar.
2. takes
2.1 recompression before packing
The tar command to package directory, then the command gzip compression after a catalog packed into one file. tar command as follows:
tar -cvf 打包后的文件名 要打包的目录
Which -v
options are displayed details can be added without.
For example, the study directories under tmp directory packaged into study.tar file:
tar -cvf study.tar /tmp/study
File packaged in theory, what is his name can be, not necessarily to .tar
the end, but in order to easily distinguish, usually give it to a .tar
filename ending.
After the package is over the top and then talking about the gzip compression command on it:
gzip study.tar
2.2 packaged at the same time compression
If you think the first pack and then compress too much trouble, there is a way can be compressed directly while packaged. Just add an option when using the tar command -z
can be.
tar -zcf study.tar.gz /tmp/study
2.3 unzip
Decompression option -x
, usage is:
tar -zxf study.tar.gz #将study.tar.gz这个文件解压缩到当前目录
3. zip, unzip
zip 压缩后的文件名 要压缩的文件
If you want to compress the directory, plus an option -r
can be.
zip -r 压缩后的文件名 要压缩的目录
Decompression command unzip, use is also very simple:
unzip 压缩包的文件名
Not high compression ratio of the zip command.
4. bzip2, bunzip2
bzip typically generated compressed file extensions .bz2
.
4.1 compressed file, does not retain the original file
bzip2 文件名
4.2 compressed file, retaining the original file
bzip -k 文件名
4.3 used in conjunction with the tar, compress the directory
tar -cjf 压缩后的文件名 要压缩的目录名
The resulting file to .tar.bz2
the end.
4.4 decompression, does not retain archive
bunzip2 压缩包的文件名
4.5 unzip the archive retention
bunzip2 -k 压缩包的文件名
4.6 unzip the file format xxx.tar.bz2
tar -xjf xxx.tar.bz2