Common linux compression commands

Source: Internet
Author: User

Common linux compression commands
Common linux compressed file extensions

*. Z files compressed by the compress program;

*. Files compressed by the gz gzip program;

*. Bz2 bzip2 files compressed by the program;

* The data packaged by the. tar program has not been compressed;

* .Tar.gz tar package files, which are compressed by gzip

* .Tar.bz2 tar package, which is compressed by bzip2

Gzip, zcat
# Gzip [-cdtv #] file name # zcat file name .gz option and parameter:-c: Output compressed data to the screen, which can be processed through data stream redirection;-d: -t: can be used to check the consistency of a compressed file ~ Check whether the file has any errors.-v: displays the compression ratio of the original file/compressed file.-#: the compression level.-1 is the fastest, but the compression ratio is the worst.-9 is the slowest, but the compression ratio is the best! The default value is-6.

Zcat can read compressed files compressed from plain text files. Not only can compress compressed files be unzipped using gzip, but zcat can also read compress and gzip compressed files.

Example 1: copy/etc/man. config to/tmp and compress it with gzip

# cd /tmp# cp /etc/man.config .# gzip -v man.config

Example 2: Since man. config is a text file, read the compressed file in Example 1.

# zcat man.config.gz

Example 3: Decompress the file in Example 1

# gzip -d man.config.gz

Example 4: compress man. config unlocked in Example 3 with the optimal compression ratio and keep the original file

# gzip -9 -c man.config > man.config.gz
Bzip2, bzcat
# Bzip2 [-cdkzv #] file name # bzcat file name. bz2 option and parameter:-c: output the data generated during the compression process to the screen-d: extracted parameter-k: keep the original file without deleting the original file-z: the compressed parameter-v: displays the compression ratio of the original file/compressed file and other information;-#: Same as gzip, all are parameters for calculating the compression ratio.-9 is the best and-1 is the fastest

Example 1: compress/tmp/man. config with bzip2

# bzip2 -z man.config

In this case, man. config is changed to man.config.bz2.

Example 2: Read the file content of Example 1

# bzcat man.config.bz2

The man.config.bz2 extracted file content is displayed on the screen.

Example 3: Decompress the file in Example 1

# bzip2 -d man.config.bz2

Example 4: compress man. config unlocked in Example 3 with the optimal compression ratio and keep the original file

# bzip2 -9 -c man.config >man.config.bz2

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.