Before the introduction, we will first introduce common compressed file extensions and list several extensions. For more information, see.
*. Z: The file compressed by the compress program.
*. Bz2: Files compressed by Bzip2.
* GZ: the files compressed by the gzip program.
*. Tar: The data packaged by the tar program has not been compressed.
* .Tar.gz: the files packaged by the tar program are compressed by gzip.
1. gzip and zcat
Gzip is the most widely used compression command. Currently, You Can uncompress files, zip files, and gzip files. The compressed files are named *. GZ. The command format is as follows:
# Gzip [-cdtv #] file name.
Parameter:-C: output the compressed data to the screen to retain the original file. For example, compress the unencrypted newfile and keep the original file. Command: gzip-C newfile> newfile.gz
-D: extract parameters. For example, the gzip-D newfile.gz command will delete the original compressed file and generate the original file.
-T: it can be used to check the consistency of a compressed file to see if there are any file errors.
-V: compression parameter, which can display the compression ratio of the source file/compressed file. For example, gzip-V newfile. this command deletes newfile.gz files.
-# Compression grade.-1 is the fastest, but the compression ratio is poor.-9 is the slowest, but the default compression ratio is-6.
2. Compress
Command operation: compress [-DCR] File Name or directory
Parameters:
-D: used for decompression. -R: It can be compressed together with files in the directory. -C Outputs compressed data as standard output.
3.bzip2 and bzcat
Command Format: Bzip2 [-CDZ] file name. Bzcat file name .bz2.
Parameter:-C: outputs the data generated during the compression process to the screen. -D: extract parameters. -Z: compression parameter. -#: Same as gzip, Gzip is used to calculate the compression ratio.-9 is the best, and-1 is the fastest.
4. Tar packaging Tool
Command Format: Tar [-cxtzjvfppn] file or directory
Parameters:
-C: Create a compressed file)
-X: extract file Parameters
-T: view the files in the tarfile. Note that when using parameters, C/X/T can only have one, and cannot exist at the same time.
-Z: whether Gzip is available at the same time, that is, whether gzip compression is required.
-J: whether to use the Bzip2 attribute.
-V: displays files during compression.
-F: use the file name. After F, the file name must be connected immediately.
-P: use the original attributes of the original file.
-P can be compressed using absolute paths.
-N: it is more important than the subsequent date to be packaged into the new file.
-Do not package the exclude file in the package process.
For example:
# Tar-CVF/tmp/etc.tar/etc // only package, do not compress.
# Tar-zcvf/tmp/etc.tar.gz/etc // compress the package with gzip.
# Tar-ztvf/tmp/etc.tar.gz // check the files in it
# Tar-zxvpf/tmp/etc.tar.gz/etc // back up files in/etc/and save their permissions.
# Tar-N '2017-9-9 '-zcvf home.tar.gz/home // only files updated compared with 2005-9-9 are backed up.