File compression and decompression, File compression and decompression
File compression and decompression
Common commands and Parameters
1 gzip
-C: output the compressed or decompressed results to the standard output.
-D decompression, equivalent to guzip
-# (1-9) specifies the compression ratio. The default value is 6.
View the file without zcat decompression.
Compression: gzip FileName
Decompress: gzip-d FileName.gz
2 bzip2
-D decompression, equivalent to bunzip
-K: Retain the original file
-# (1-9) specifies the compression ratio. The default value is 6.
View the file without decompressing bzcat.
Compression: bzip2 FileName
Decompress 1: bzip2-d FileName.bz2
Decompress 2: bunzip2 FileName.bz2
3 xz
A compression command to replace gzip and bzip2
-D Decompression
-K: Retain the original file
-# (1-9) Specify the compression ratio.
View files without decompression of xzcat
Compression: xz Fileanme
Decompress: xz-d Filename. xz
The preceding three common compression commands gzip, bzip2, and xz are used with the same parameters. Remember, you can easily get started with either of them.
4 tar
Packaging tool to package multiple directories into one file. It does not support compression.
-C. Create a package file
-F specifies the package file name (-f must be put together with the file name)
-V shows the packaging process
-R: append an object to an archive object
-X expands the archive file, which is used in combination with-v and-f.
-T view the file list in the archive file
-C. decompress the package to the specified directory.
Usually used together with a compression Tool
-J: adopts bzip2 Compression
-Z: gzip Compression
-J: adopts xz Compression
Eg. Compression/data
Tar-zcvf/home/redhat/data.tar.gz/data/
/Home/redhat.tar.gz is the compressed file name.
/Data is the directory to be compressed
Decompress/home/redhat/date.tar.gz