Linux under Zip, tar, tar.gz, tar.bz2 detailed

Source: Internet
Author: User
Tags bz2 file size rar

Compression, decompression is the daily work of the two common operations, for Windows platform, the most commonly used format is zip and rar, most of the domestic use of RAR, most of the foreign is using zip.

For Unix-like platforms, the commonly used format is less tar and tar.gz,zip, and RAR has few.

ZIP format
Zip format is open and free, so widely used in Windows, Linux, MacOS platform, to say what the shortcomings of the zip, that is, its compression rate is not very high, as well as the RAR and tar.gz and other formats.

The command to compress a file or folder into a ZIP document is as follows:

The code is as follows Copy Code
Zip-r Archive_name.zip file_to_compress
Zip-r Archive_name.zip directory_to_compress/

The following commands are extracted for the ZIP document:

Unzip Archive_name.zip
TAR format
Strictly speaking, Tar is just a packaged format, does not compress files, mainly for file management, so the size of the packaged document is generally much larger than zip and tar.gz, but this format also has obvious advantages, such as the packaging speed is very fast, packaging, the CPU occupancy rate is very low, Because you don't need compression.

The command to package a file or folder as a tar document is as follows:

The code is as follows Copy Code
TAR-CVF Archive_name.tar file_to_compress
TAR-CVF Archive_name.tar directory_to_compress

The command to unpack a tar document is as follows:

TAR-XVF Archive_name.tar
TAR. GZ
Tar.gz can be said to be a supplement to tar, it will compress the file, and the compression rate is slightly better than the zip, but the CPU occupancy rate is not high. Most open source software or source code under the Linux platform is in this format.

The commands for packaging files or folders into tar.gz documents are as follows:

The code is as follows Copy Code
TAR-ZCVF archive_name.tar.gz file_to_compress
TAR-ZCVF archive_name.tar.gz directory_to_compress

The command to extract a tar.gz document is as follows:

The code is as follows Copy Code
TAR-ZXVF archive_name.tar.gz

TAR. BZ2
Compared to the above several formats, TAR.GZ2 has the highest compression rate, but the time required for compression is the longest, the CPU occupancy rate is the highest. The command to compress a file or folder to tar.bz2 is as follows:

The code is as follows Copy Code
TAR-JCVF archive_name.tar.bz2 file_to_compress
TAR-JCVF archive_name.tar.bz2 directory_to_compress

The command to extract a tar.bz2 file is:

The code is as follows Copy Code
TAR-JXVF archive_name.tar.bz2

I have the latest version of the WordPress 3.5.1 version of the folder in the above several formats compressed file size respectively:

The code is as follows Copy Code
[Root@lichao files]# Ls-l
Total 27764
Drwxr-xr-x 5 root 20:53 wordpress 4096
-rw-r--r--1 root root 13250560 Apr 02:23 Wordpress.tar
-rw-r--r--1 root root 4628845 Apr 02:27 wordpress.tar.bz2
-rw-r--r--1 root root 5012223 Apr 02:18 wordpress.tar.gz
-rw-r--r--1 root root 5468888 Apr 02:18 wordpress.zip

It can be said that the above several types of formats have their advantages and disadvantages, you need to be in the compression rate, compression and decompression time consuming and CPU utilization to find a balance point. I've been using the zip format before, because it looks like the command is easy to remember, but from now on it may be tar.gz more.

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.