First, related terms
Compression: An operation that reduces the file storage space by the algorithm and takes time to change space
Compression ratio: The ratio of size before compression to a file compression operation
Ii. compression tools commonly used in Linux
Compress/uncompress
Is incremented after the file name. The suffix name of z; xxx. Z, rarely used, poor algorithm
Gzip/gunzip
Adds a. gz suffix after the file name: xxx.gz
-D decompression, equivalent to Gunzip
-number--fast--best is compressed at level 1-9, default is 6
-C outputs the compression results to standard output, but does not compress the source files and can be packaged using redirection
Bzip2/bunzip2
Suffix name:. bz2
-D Decompression
-K bzip2 The source file is deleted by default when compressing and decompressing, using this option to preserve the source file
-C outputs the compression results to standard output, but does not compress the source files
-1-9 default compression level is 9
Xz/unxz
Suffix name:. xz
Xz,unxz,xzcat,lzma,unlzma,lzcat
-D decompression
-K Keep the original file
-0-9 default compression level is 6
Zip/unzip
In order to be compatible with Windows development, mainly in win, the main role is packaging, source files are not deleted, suffix name:. zip
Zip ZipFile file
-p password
Unzip
-L View a list of files in a compressed package
Tar: archive, which itself does not have the compression function, can be used
Options:
Main options
-C: Create an archive file
-r: Append file at the end of the archive file
-T: List the contents of the archive file
-u: Append to the archive file when the file is newer than the contents of the file
-x: Get the file from the archive, release the file
Accessibility Options:
-F: The option to indicate the profile when using the archive file
-C: When releasing files in the file, do not release to the current directory, but specify additional paths
-j: Call bzip2 compression, used primarily when creating an archive file
-j: Call XZ compression
-Z: Call the gzip tool
-Z: Call the Compress tool
-K: When releasing files in the file, if the target location has the same name as the file, the file is not released, and an error
--exclude=pattern: Files that are PATTERN-matched are not released when files are released in the archive
Example:
tar-cjf/backup/etc-' Date +%f '-' date +%h '. tar.xz/etc
Compression and decompression tools commonly used in Linux