Comparison of Linux compression tools __linux

Source: Internet
Author: User
Tags bz2 uncompress zipinfo
[sharing] performance comparisons for Linux compression toolsOverview of Linux compression tools

In the Linux system, many compression tools are provided, which, while convenient, will inevitably cause some confusion. The author through a period of finishing, to straighten them out, hoping to be helpful to everyone:
First of all, let's take a look at the following "compression package extension and compression tool corresponding table", through this table, we know the download of the online package, what software to solve.
Tool name Compression Package extension
Gzip/gunzip ". Gz"
Compress/uncompress ". Z
Zip/unzip ". zip"
Bzip2/bunzip2 ". bz2"
Lha ". Lzh"
Next, we measure their compression efficiency and performance by example:

Test One:
Test data: The source file is a database file with a size of 5,244,928;
Test results:
gzip:19,136,2 seconds
compress:17,769,1 seconds
zip:19,261,2 seconds
bzip2:1902,2 seconds
Test Two:
Test data: The source file is a/etc directory of the TAR package, its size is 2,631,680;
Test results:
gzip:551,736,2 seconds
compress:877,391,3 seconds
zip:551,856,3 seconds
bzip2:478,512,11 seconds
Test Three:
Test data: The source file is an AVI video file, its size is 23,157,760;
Test results:
gzip:17,151,395,43 seconds
Compress: Compression failed, 43 seconds
zip:17,151,509,42 seconds
bzip2:16,587,991,2 minutes, 40 seconds.
Through the above experiment, I think if you need high compression rate, choose BZIP2, otherwise the best choice is gzip, it's better performance, and is pure free software: gzip is the GNU zip.
Under the Linux/unix system, these compression software are not packaged directly into a directory, and when you need to do this, you typically use tar for archiving, packaging the entire directory into a tar package, and compressing it with compression software. Let's take a look at all the files in the/etc directory for example:
TAR–CVF Etc/etc (a Etc.tar will be generated in the current directory)
Gzip Etc.tar (the Etc.tar will be compressed into etc.tar.gz)
For more information on tar, we will explain the article.
OK, so much, let's take a look at the usage of these compression tools together.


II. Overview of Linux compression tools

1.gzip and Gunzip
Compress package Extension: ". Gz"
Characteristics:
1 It is the pure free software, the performance is good.
2 If no parameter is added, the original file will be deleted after the compressed file is generated.
command to use:
1) Compress a file:
Gzip file This will generate file.gz, delete the original files;
2 Compress a file and keep the source file:
Gzip–c a > a.gz
3) Increase the compression rate: Gzip–9 file
Note: The compression level can be from 1-9, the larger the number of compression effect, but the longer it takes, the default value is 6.
4) Decompression:
Gzip–d file.gz or
Gunzip file.gz
5) Display Details:
Gzip–v file
6 Display version information:
Gzip–v

2.BZIP2 and BUNZIP2
Compress package Extension: ". bz2"
Characteristics:
1 It adopts a new compression algorithm, and the compression effect is better than the traditional lz77/lz78 compression algorithm.
2 If no parameter is added, the original file will be deleted after the compressed file is generated.
command to use:
1) Compress a file:
bzip2 file will generate FILE.BZ2, delete the original files;
2 Compress a file and keep the source file:
Bzip2–k file
3) Increase the compression rate: Bzip–9 file
Note: The compression level can be from 1-9, the larger the number of compression effect is better, but the longer it takes.
4) Decompression:
Bzip2–d file.bz2 or
BUNZIP2 file.bz2
5) Display Details:
Bzip2–v file
6 Display version information:
Bzip2–v
Related tools:
If you have an error with bzip2 compressed files, you can try to use Bzip2recover to recover:
Bzip2recover file-bad.bz2

3.compress and Uncompress
Compress package Extension: ". Z
Characteristics:
1 It is a long history of the compression process, in many UNIX systems can be found;
2) By default, the original file is deleted when the compressed file is generated.
command to use:
1) Compress a file:
Compress file
2 Compress a file and keep the source file:
Compress–c a > A.z
3) Increase the compression rate: COMPRESS–B9 file
Note: The compression level can be from 9-16, the larger the number of compression effect is better, but the longer it takes. The preset value is 16.
4) Decompression:
Compress–d file. Z or
Uncompress a.z
5) Display Details:
Compress–v file
6 Display version information:
Compress–v

4.zip and Unzip
Compress package Extension: ". zip"
Characteristics:
1 It is a widely used compression program, its version spans over 10 kinds of operating systems and hardware structure platform;
2) By default, the original file is not deleted when the compressed file is generated.
command to use:
1) Compress a file:
Note: If you are compressing a folder, add the-r parameter to invoke recursive compression, such as:
Zip-r Temp.zip Temp
Zip ZipFile file (ZipFile is the compressed filename, file name to compress)
2 Compress a file and delete the source file:
Zip–m file
3) Increase the compression rate: Zip–9 file
Note: The compression level can be from 1-9, the larger the number of compression effect is better, but the longer it takes. The preset value is 6.
4) Decompression:
Zip–d File.zip or
Unzip File.zip
5) Display Details:
Zip–v file
6 Display version information:
Zip–v
Related tools:
Linux also provides a tool called Zipinfo to view the details of zip compressed files:
Zipinfo File.zip


Third, other compression/decompression tools

In addition to these four compression/decompression tools, the following three compression/decompression tools are available under Linux:

1.lha
LHA is a compression program that evolves from Lharc, which, when compressed, produces an extension with ". Lzh". It's simpler to use, and it can be packaged directly into a directory:
1) Compress a file:
Lha–a lhzfile file (Lhzfile is the compressed filename, file name to compress)
2) Decompression:
Lha–xiw=/tmp lhzfile (where/TMP is the uncompressed storage directory, Lhzfile is the compressed file name)
3) Compress a directory:
Lha–a Lhzfile Directory

2.gzexe
This is a very special compression tool that is used to compress executable files. When you execute an executable file that is Gzexe compressed, the file is automatically decompressed and then executed, as does the execution of a generic executable file.
Of course, this process will take up some of the system resources, only if your free disk space is very limited to recommend use.
1) compression
Gzexe Program
This will generate a program~, in case of compression failure can be restored, when you determine the compression can be used, you should delete it, otherwise it will be white compression.
2) Decompression
Gzexe–d Program

3.unarj
If you have some ARJ compressed package, you can use Unarj to unlock it, but it can only be solved, but can not perform compression. ARJ compression tools are not available on Linux.
Decompression, very simple: Unarj e arjfile

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.