Linux Learning Summary (14) Packaging and compression of files

Source: Internet
Author: User
Tags bz2

File compression and packaging, under WinDOS we are familiar with. rar and. zip files, which are two kinds of compressed files, they support the compression of individual files and multiple files. WinDOS We do not mention the concept of packaging, although the compression of multiple files must have a packaging process.
The difference between packaging and compression, from the literal meaning can be seen, packaging is a number of files bundled together, the purpose is to facilitate the copying and transmission, compression is usually packaged after the re-processing, the purpose is to save resources, such as saving network bandwidth, improve transmission efficiency.
From the above conclusions, we can understand why Linux has so many packaging compression tools, windos requirements to operate as simple as possible, Linux requires efficiency and control.
Several packaging compression tools and their file name suffixes correspond to the relationship:
Tar-----. Tar
Gzip------. GZ
bzip2-----. bz2
XZ--------. XZ
Zip-------. zip

One for the processing of individual files:

Three types of compression tools are introduced:
1 gzip compress the file to get the. gz suffix of the package, do not compress the directory
Format gzip filename
gzip-d filename.gz Decompression
gzip-c filename >> filname.gz Preserve original file compression
GZIP-DC filename.gz >> filename retain original file decompression Bzi
2.bzip2
Usage basic and gzip consistent, get a. bz2 suffix package
Compress bzip2 filename
Decompression bzip2-d filename.bz2
3 XZ
Compression XZ Filname
Decompression xz-d FILENAME.XZ

Two for the processing of multiple files:

1. Package the file first, the tar command
-C Create Package
-V Visualization
-F Specify File
-X Unpack the package
Format TAR-CVF Filename.tar filename1 filename2
Do not want to see the process-V can not
TAR-XVF Filename.tar
-C To specify the unpacking path
2. Combined with the above three compression methods, can be packaged and compressed
-Z Compression with gzip
-j compression with bzip2
-j with XZ compression
So the three packaged and compressed formats are:
TAR-ZCVF filename.tar.gz filename1 filename2
TAR-JCVF filename.tar.bz2 filename1 filename2
TAR-JCVF filename.tar.xz filename1 filename2
The corresponding decompression format is:
TAR-ZXVF filename.tar.gz
TAR-JXVF filename.tar.bz2
TAR-JXVF FILENAME.TAR.XZ
If you don't remember the parameters of several formats, then the decompression of a lazy way, without formatting,
TAR-XVF filename.tar.gz or filename.tar.bz2 or FILENAME.TAR.XZ
The system automatically matches the format to be decompressed
3.zip Compression and Unzip decompression
The advantage of this format is that both the WinDOS and Linux environments are supported, so to transfer files in that two environments preferred zip compression
Format zip filename.zip filename1 filename2
Filename.zip with path to specify the path of the compressed package
-R Cascade Compression Directory
Decompression Unzip Filename.zip
-D Specify Unzip directory
Unzip filename.zip-d/tmp/
4 Viewing of several packages
Tar package TAR-TF View the list of files in the package
Gzip Package Zcat View the contents of the files in the package
BZIP2 Bag Bzcat
XZ Bag Xzcat
5. Comparison of several tools
Gzip bzip2 XZ Direct compression and decompression are not retained for the original file unless redirected.
Tar zip default reserved Original file

Linux Learning Summary (14) Packaging and compression of files

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.