I. Common compression commands
In Linux, the zip file has the following extension:
Gz:gzip compression
BZ2:BZIP2 compression.
Tar.:tar program packaged data, no compression
Tar.gz:tar is packaged and compressed by gzip.
Tar.bz2:tar packaged and compressed by bzip2
(Note that the extensions in Linux are not related to file attributes, just to keep us in mind.)
BZIP2 is better than gzip compression, these two compression commands can only compress one file, if you want to compress a large pile of files, it is necessary to use tar to package.
1.gzip, Zcat
The zip file extension is gz. Syntax such as:
gzip [-cdtv#] File name
Zcat file name. gz
Next we copy the/etc/fstab file to the ~ and compress it.
As you can see, the original file does not exist after compression. gzip compressed files are available in Windows that can be decompressed by WinRAR. The above 54% is the compression ratio shown.
We will then read the contents of the compressed file. Since it is a text file, it can be read using Zcat. (Cat reads text files, Zcat reads compressed text)
Unzip the file above
Note that the original compressed file is not here.
2.bzip2,bzcat
BZIP2 was developed to replace Gzip. Usage is basically the same as gzip.
bzip2 [-cdkzv#] File name
Bzcat file name. bz2
-C: Displays the data generated during the compression process.
-D: Extracted parameters
-K: Keep the original file, do not delete
-Z: Compressed parameters
-V: Show Compression ratio, etc.
A simple way to memorize commands like,
gzip, Gunzip, BZIP2, BUNZIP2
3. Packaging Command Tar
Gzip and bzip2 can only compress a single file, and if you want to compress multiple files, use the Package command. Several important uses of tar are as follows
tar [-j|-z] [CV] [-f new filename] filename <=== packaging and compression
tar [-j|-z] [TV] [-F New file name] <==== view file name
tar [-j|-z] [XV] [-F new file name] [-C directory] <==== decompression
Chapter9: File and File system compression and packaging (1) Linux common compression commands