Compression of files under Linux

Source: Internet
Author: User

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 and Zcat

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 and Bzcat

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.