Common ZIP file extensions for Linux
*. Z Compress program compressed files;
*.gz gzip files compressed by the program;
*.bz2 bzip2 files compressed by the program;
*.tar The TAR program is packed with data that has not been compressed;
*.tar.gz Tar program packaged files, which are also compressed by gzip
*.tar.bz2 Tar program packaged files, which are bzip2 compressed
gzip, Zcat
# gzip [-cdtv#] File name # zcat file name. GZ Options and Parameters:-C : Outputs the compressed data to the screen, which can be processed by data flow redirection; -D: the extracted parameters;-T : Can be used to verify the consistency of a compressed file ~ To see if there are errors; -V: can display the original file/compressed file compression ratio and other information;-# : Compression level, 1 the fastest, but the compression ratio is the worst, 9 slowest, but the best compression! Default is-6
Zcat can read the compressed files of plain text files, not only compress compressed files can be unpacked using gzip, while zcat this command can simultaneously read compress and gzip compressed files.
Example one: Copy the/etc/man.config to/tmp and compress it with gzip
# cd/tmp# Cp/etc/man.config. # gzip-v Man.config
Example two: Since Man.config is a text file, please read the contents of the compressed file of example one
# Zcat Man.config.gz
Example three: Extracting a file from sample one
# gzip-d Man.config.gz
Example four: Man.config with the best compression ratio and retains the original file
# gzip-9-C man.config > man.config.gz
BZIP2, Bzcat
# bzip2 [-cdkzv#] File name # bzcat file name. bz2 options and Parameters: -C: Output data generated by the compression process to the screen-D : decompressed parameter-K : retains the original file without deleting the original file-Z : Compression parameter-V : can display the original file/compressed file compression ratio and other information;-# : Same as gzip, all in the calculation of compression ratio parameters, 9 best, 1 fastest
Example one: Compress just the/tmp/man.config with bzip2
# bzip2-z Man.config
At this point Man.config will become man.config.bz2.
Example two: Read the file contents of example one
# Bzcat MAN.CONFIG.BZ2
The contents of the file after man.config.bz2 are displayed on the screen.
Example three: Extracting a file from sample one
# bzip2-d MAN.CONFIG.BZ2
Example four: Man.config with the best compression ratio and retains the original file
# bzip2-9-C man.config >man.config.bz2
Common compression commands for Linux systems