There are many compression commands supported under Linux, and the technology compression techniques used by different commands are not the same, so it may be impossible to compress and unzip the files with each other. For ease of use, Linux adds the appropriate extension to the compressed file, and below we list several common zip file scheme extensions:
- *. Z Compress program Compression
- *.GZ gzip Program Compression
- *.BZ2 bzip2 Program Compression
- *.tar the TAR program to package data that has not been compressed
- *.tar.gz Tar program packaged data, which is compressed by gzip
- *.tar.gz2tar program-packaged data, which is compressed by bzip2
The common compression commands under Linux are gzip and bzip2, and compress is no longer popular. Gzip is a compression command developed by the GNU program to replace Compress. Later GNU had developed a compression ratio better than the bzip2 to replace Gzip.
As for the tar command, it is a packaged command under Linux, which later has the compression function.
The Compress compression command is now no longer in use, and the gzip command can be decompressed *. Z compressed file, no longer described here.
Gzip is the most widely used compression command that can decompress compress,zip,gzip and other software-compressed files, gzip compressed file extension *,gz.
Common parameters are as follows:
-C: Output compressed data to the screen, can be processed by data flow redirection;
-D: the extracted parameters;
-T: Decompression compressed file consistency, see if the file error;
-V: Show compression ratio;
-#: Compression level, 1 the fastest, but the worst compression ratio,-9 slowest, preferably 6.
For example:
The source file disappears after gzip compression.
Zcat can read plain text files that have been compressed by gzip.
For example:
Unzip as follows:
BZIP2 is to replace gzip to provide a higher compression ratio, compressed after the source file disappears, you can decompress the *.bz,*.bz2.*.tbz,*.tbz2.
Common parameters:
-C: Output compressed data to the screen, can be processed by data flow redirection;
-D: the extracted parameters;
-K: The compression process retains the source file;
-Z: Compression parameters;
-V: Show compression ratio;
-#: Compression level, same as gzip.
Example 1: Compressing a file
Bzcat can read compressed files that are bzip2 compressed by a plain text file.
Example 2:
Example 3: Decompression
Example 3: Use the best compression ratio and keep the source files (using redirects).
You can use the BUNZIP2 command instead of bzip2-d to extract the files.
Compression of files under Linux