Linux package Compression

Source: Internet
Author: User

Linux package Compression

  • Collation
  • 1. gzip
  • 2.bzip2
  • 3. tar
    Collation

    Compression benefits

    1. Save space 2. save bandwidth

    Solution

    There are various types of compressed files. Why? The compression technology is updated, and the compression methods are not exactly the same. Different suffixes are easy to differentiate.

    The earliest compress command-type compress is not very useful now. Later, a new generation of compression command gzip (GNU zip) was developed, and the bzip2 compression command with better compression ratio was developed.

    Note: The two new commands mentioned above can only compress a single file, but cannot compress directories. Therefore, the software should be packaged.

    However, packaging only combines all programs without praying for compression. Later, GUN planned to combine the packing box compression function to achieve a perfect combination.

    The development process of this compression,

    Detailed explanation


    1. gzip

    Format: gzip [-cd #] File Name

    Parameters:

    -C: output to the standard output (in this case, you must specify the output file) and save the original file.

    -D: Extract

    -#: Compression level. The larger the number, the more severe the compression, the longer the compression time. From 1 to 9. The default value is 6.

    Instance:

    Hello is a file, gzip hello is used, and the file is compressed, but the source file also disappears.

    How can we see the content in the compressed file? Yes. Run the zcat command:

    Uncompress: gzip-d hello.gz

    Re-write the compressed file with the specified name? Redirect (the source file still exists ):

    Compressed files in different ranges:

    2.bzip2

    Format: bzip2 [-zdc #] File Name

    Parameters:

    -C: output to the standard output (in this case, you must specify the output file) and save the original file.

    -Z: Compression

    -D: Extract

    -#: Compression level. The larger the number, the more severe the compression, the longer the compression time. From 1 to 9. The default value is 6.

    Instance:

    Compressed file hello: bzip2 hello (to hello.bz2)

    Decompress hello.bz2: bzip2-d hello.bz2

    Zip to a file named hel.bz2: bzip2-c hello> hel.bz2

    Content of the hello.bz2 compressed file: bzcat hello.bz2

    3. tar

    Format: tar [-cxt zjvf] file and directory

    Parameters:

    -C: create Compression

    -X: Extract

    -T: view the compressed file content

    Note: Only one of the three cxf parameters can be used at a time.

    -Z: gzip compression during packaging

    -J: Package and bzip2 Compression

    -V: displays files during compression.

    -F: use the file name

    Note: After the-f parameter, the file name is directly added, that is, the end of f, and the parameter cannot be added.

    -Cvf package only

    Instance:

    Compression directory del: the file name directory/file name after the tar parameter is compressed (you can see that the source file still exists)

    Decompress: Enter the tar-xvf compressed file in the desired directory:

    Compression to gz format:

    Conclusion: tar.gz

    • Compression: tar-zcvf a.tar.gz
    • Decompress: tar-zxvf a.tar.gz

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.