Linux Compression Packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool

Source: Internet
Author: User

Note content:

L 6.1 Compression Packaging Introduction

L 6.2 gzip compression tool

L 6.3 bzip2 compression tool

L 6.4 xz compression tool

Note Date:2017.8.5

6.1 Compression Packaging Introduction

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/08/65/wKiom1ngmNDxSepbAAgq4FnYMgw123.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 74.png "alt=" Wkiom1ngmndxsepbaagq4fnymgw123.png "/>

It is well known that file compression takes up a small amount of disk space, and because the size of the file is smaller after compression, it is faster to transfer over the network and reduces the use of network bandwidth resources.

The network in the server room is different from the home, the network of the general server is the upper and lower line. The home network only downloads fast, the upload speed is slow, therefore the server room network bandwidth is more expensive, the compressed file is one of the methods of saving the bandwidth resources.

in the Linux file suffix can be arbitrarily customized, but it is best to follow the regular format to define the file suffix, which facilitates the convenience of distinguishing and identifying files.



6.2 gzip compression tool

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/08/65/wKiom1ngmNWSMuDNAAoZRBVtvms416.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 303.png "alt=" Wkiom1ngmnwsmudnaaozrbvtvms416.png "/>


For example I use gzip to compress a 1.txt file:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/A7/1B/wKioL1ngliCQaF3IAAID2Pw8SNI912.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 327.png "alt=" Wkiol1nglicqaf3iaaid2pw8sni912.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/A7/1B/wKioL1ngliCz1ZlcAAIk4zF8egc673.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 329.png "alt=" Wkiol1nglicz1zlcaaik4zf8egc673.png "/>


Unzip 1.txt File:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/08/65/wKiom1ngmNejGc0OAAH4sU9WOa8777.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 343.png "alt=" Wkiom1ngmnejgc0oaah4su9woa8777.png "/>

Since this file has some virtual space before compression, the file size after compression is different, just like a sponge.

Gzip can specify the level of compression, there are altogether 1-9 levels, the default is 6 levels,1 levels is the least rigorous compression, So the compressed file is larger, but consumes less CPU resources. 9 is the most rigorous compression, but consumes more CPU Resources, in general, the compression level is the default.


Specify the compression level example:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/08/65/wKiom1ngmNiCUohfAAJRCl8Bgp0292.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 513.png "alt=" Wkiom1ngmnicuohfaajrcl8bgp0292.png "/>

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/A7/1B/wKioL1ngliKA8NEfAALl1UDVO7I198.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 515.png "alt=" Wkiol1nglika8nefaall1udvo7i198.png "/>


The Gunzip command can also unzip the file:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/08/65/wKiom1ngmNnTPDIuAAKJ6Zc0U2U191.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 536.png "alt=" Wkiom1ngmnntpdiuaakj6zc0u2u191.png "/>


use the file command to view information about a compressed file:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/A7/1B/wKioL1ngliPCdk0ZAAIRhGCrh0M266.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 558.png "alt=" Wkiol1nglipcdk0zaairhgcrh0m266.png "/>


use the zcat command to view the contents of a zip file in gz format, which is actually extracted and then viewed:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/A7/1B/wKioL1ngliTxdXlaAACEmUROLZY717.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 599.png "alt=" Wkiol1nglitxdxlaaacemurolzy717.png "/>


from the above experiment can know that using gzip compressed file after the original file will disappear to become a compressed file, but the gzip - c option allows the original file does not disappear, Regenerate a compressed file, and you can also specify a storage path for the compressed file:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/08/65/wKiom1ngmNvzADgCAANmoV0Z3pc099.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 691.png "alt=" Wkiom1ngmnvzadgcaanmov0z3pc099.png "/>


The relative decompression can also do this:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/08/65/wKiom1ngmN3AnZ2ZAARi4cYGeuo240.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 707.png "alt=" Wkiom1ngmn3anz2zaari4cygeuo240.png "/>

Note:gzip cannot compress the catalog




6.3 bzip2 compression tool

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/A7/1B/wKioL1ngliqh8dqBAAj_hk2P8Ic840.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 744.png "alt=" Wkiol1ngliqh8dqbaaj_hk2p8ic840.png "/>

This bzip tool is more compressed than gzip , which means more CPU resources, and the two tools have different compression algorithms.

Minimal installation may not have this tool and need to be installed with the yum install-y bzip2 command:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A7/1B/wKioL1nglzvRCdhZAASexHd2WCk111.png "title=" Linux Compression Packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 849.png "alt=" Wkiol1nglzvrcdhzaasexhd2wck111.png "/>


The usage of bzip2 and gzip is almost identical:650) this.width=650; "Src=" Https://s4.51cto.com/wyfs02 /m01/08/65/wkiom1ngmooiecgdaalkiebe4as133.png "style=" Float:none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 875.png "alt=" Wkiom1ngmooiecgdaalkiebe4as133.png "/>


Unzip the same can use two commands:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/A7/1B/wKioL1ngli3Tb2FSAAHVcPznXMk071.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 893.png "alt=" Wkiol1ngli3tb2fsaahvcpznxmk071.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/08/65/wKiom1ngmOWwRoZBAAHcD1BPqLA222.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 895.png "alt=" Wkiom1ngmowwrozbaahcd1bpqla222.png "/>


You can specify a storage path for the compressed file by adding the-C option:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/08/65/wKiom1ngmOaRfANEAAJ7m6IFOGM423.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 918.png "alt=" Wkiom1ngmoarfaneaaj7m6ifogm423.png "/>


The relative decompression can also do this:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/A7/1B/wKioL1ngljCydC4HAAKgw3aY9Ig893.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 934.png "alt=" Wkiol1ngljcydc4haakgw3ay9ig893.png "/>


Bzip2 also has a compression level, you can specify the level of compression, and also the compression level of 1-9, the default compression level is 9, so you generally do not need to specify the compression level.

Example:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/08/65/wKiom1ngmOaTNk_aAAFNszQIt64352.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1002.png "alt=" Wkiom1ngmoatnk_aaafnszqit64352.png "/>


You can use file to view the information for a compressed file:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/A7/1B/wKioL1ngljGCxItQAAEzZYsgQlw045.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1024.png "alt=" Wkiol1ngljgcxitqaaezzysgqlw045.png "/>


The Bzcat command can view the contents of a compressed file in the bz2 format, the same principle as the gzip zcat command:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/A7/1B/wKioL1ngljGQ9VrSAACY3WL2HcM765.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1070.png "alt=" Wkiol1ngljgq9vrsaacy3wl2hcm765.png "/>




6.4 xz compression tool

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/08/65/wKiom1ngmOyQNzkeAAsu3xLMdFE115.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1084.png "alt=" Wkiom1ngmoyqnzkeaasu3xlmdfe115.png "/>

The XZ compression tool is similar to the previous two compression tools, but it is not often used, but in a common tar package, a compressed package with a suffix of tar.xz is often seen . So this tool is also to be understood.

Compression Example:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/08/65/wKiom1ngmO3BbbVqAAHipU7nnmw725.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1172.png "alt=" Wkiom1ngmo3bbbvqaahipu7nnmw725.png "/>

from the compression results can be seen, this xz tool on the file compression than the first two tools more ruthless, directly compressed to dozens of K , the corresponding more CPU -intensive resources.


the same xz tool also has a compression level, you can specify the level of compression, is also the compression level of the 1-9, the default compression level is 6 .

Unzip Example:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/A7/1B/wKioL1ngljeQ400bAAF2N7frbsE105.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1282.png "alt=" Wkiol1ngljeq400baaf2n7frbse105.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/A7/1B/wKioL1ngljfAetTsAAFj7yj2u1Q468.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1284.png "alt=" Wkiol1ngljfaettsaafj7yj2u1q468.png "/>


You can specify a storage path for the compressed file by adding the-C option:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/08/65/wKiom1ngmO7xRgYsAAHQBXJfM7k338.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1307.png "alt=" Wkiom1ngmo7xrgysaahqbxjfm7k338.png "/>


Decompression can also do this:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/08/65/wKiom1ngmO_R2ct5AAIEj9Ws5ds921.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1320.png "alt=" Wkiom1ngmo_r2ct5aaiej9ws5ds921.png "/>


Xzcat command to view the contents of a compressed file:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/A7/1B/wKioL1ngljmRF4P2AACD8mlBbbw235.png "style=" float : none; "title=" Linux Compression packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1341.png "alt=" Wkiol1ngljmrf4p2aacd8mlbbbw235.png "/>


You can use file to view the information for a compressed file:

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/A7/1B/wKioL1nglqyxz_coAAEG4GWthpA096.png "title=" Linux Compression Packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool 1363.png "alt=" Wkiol1nglqyxz_coaaeg4gwthpa096.png "/>

This article is from the "12831981" blog, please be sure to keep this source http://12841981.blog.51cto.com/12831981/1972193

Linux Compression Packaging Introduction, gzip compression tool, bzip2 compression tool, XZ compression tool

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.