Chapter9: File and File system compression and packaging (1) Linux common compression commands

Source: Internet
Author: User

I. Common compression commands 

In Linux, the zip file has the following extension:

Gz:gzip compression

BZ2:BZIP2 compression.

Tar.:tar program packaged data, no compression

Tar.gz:tar is packaged and compressed by gzip.

Tar.bz2:tar packaged and compressed by bzip2

(Note that the extensions in Linux are not related to file attributes, just to keep us in mind.)

BZIP2 is better than gzip compression, these two compression commands can only compress one file, if you want to compress a large pile of files, it is necessary to use tar to package.

1.gzip, Zcat

The zip file extension is gz. Syntax such as:

gzip [-cdtv#] File name

Zcat file name. gz

Next we copy the/etc/fstab file to the ~ and compress it.

As you can see, the original file does not exist after compression. gzip compressed files are available in Windows that can be decompressed by WinRAR. The above 54% is the compression ratio shown.

We will then read the contents of the compressed file. Since it is a text file, it can be read using Zcat. (Cat reads text files, Zcat reads compressed text)

Unzip the file above

Note that the original compressed file is not here.

2.bzip2,bzcat

BZIP2 was developed to replace Gzip. Usage is basically the same as gzip.

bzip2 [-cdkzv#] File name

Bzcat file name. bz2

-C: Displays the data generated during the compression process.

-D: Extracted parameters

-K: Keep the original file, do not delete

-Z: Compressed parameters

-V: Show Compression ratio, etc.

A simple way to memorize commands like,

gzip, Gunzip, BZIP2, BUNZIP2

3. Packaging Command Tar

Gzip and bzip2 can only compress a single file, and if you want to compress multiple files, use the Package command. Several important uses of tar are as follows

tar [-j|-z] [CV] [-f new filename] filename <=== packaging and compression

tar [-j|-z] [TV] [-F New file name] <==== view file name

tar [-j|-z] [XV] [-F new file name] [-C directory] <==== decompression

Chapter9: File and File system compression and packaging (1) Linux common compression commands

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.