Which Is the Best Compression Tool for Linux?

Take a Look at Zip, Gzip, and bzip2

ZIP FILE CONCEPT
  cnythz/Getty Images 

When it comes to finding file compression tools in Linux, you are bound to encounter zip, gzip and bzip2. Which one is the best compression tool for you depends in part on what you are planning to compress. A series of tests put these three tools through their paces to see which one is best. 

Best Tool for Compressing Windows Documents

The first test uses each compression tool on a single file type to determine how each tool handles the file in question.

This series of tests ran on a Windows document in the ​Microsoft DOCX format.

Using the default settings, the results are:

ToolFile Size
Initial Filesize12202 bytes
zip9685
gzip9537
bzip210109

Using the maximum compression settings on the same file delivered similar results. Using the maximum compression didn't deliver better results than using the default settings.

ToolFile Size
Initial Filesize12202 bytes
zip9677
gzip9530
bzip210109

Running this same test on two other files, one containing text only and one containing text, images, and formatting, delivered the same result: The maximum compression settings didn't make much difference in the results. 

In all three tests, gzip comes out on top in all categories and bzip2 is the least effective.

Best Tool for Compressing Images

The next test shows the results of compressing images in PNG, JPG, Bitmap, and GIF formats. In theory, JPG files are already compressed and therefore may not compress at all and could, in theory, make the file bigger.

The test results illustrated that compressing the JPB format images had little effect.

PNG File

ToolFile Size
Initial Filesize345265
zip345399
gzip345247
bzip2346484

JPEG File

ToolFile Size
Initial Filesize44340
zip44165
gzip44015
bzip244281

Bitmap File

ToolFile Size
Initial Filesize3113334
zip495028
gzip494883
bzip2397569

GIF File

ToolFile Size
Initial Filesize6164
zip5772
gzip5627
bzip26051

In all cases, gzip came out on top again except for the humble bitmap. On the bitmap image, the bzip2 compression produced a tiny file in comparison to the original and the other compression formats.

Best Tool for Compressing Audio Files

The most common audio format is ​MP3, which has already been compressed, so the tools did not make much difference in the size of the two files that were tested.

File 1

ToolFile Size
Initial Filesize5278905
zip5270224
gzip5270086
bzip25270491

File 2

ToolFile Size
Initial Filesize4135331
zip4126138
gzip4126000
bzip24119410

Best Tool For Compressing Video

For this test, two video files were tested. As with MP3, the MP4 file already contains a level of compression. The FLV file does not have any level of compression as it is a lossless format.

MP4

ToolFile Size
Initial Filesize731908
zip478546
gzip478407
bzip2478042

FLV

ToolFile Size
Initial Filesize7833634
zip4339169
gzip4339030
bzip24300295

Both file formats were compressed, and on both, bzip2 did the best job, although the results were similar.

Executables

The last category contains executables. Because executables are compiled code, it's no surprise that they don't compress well.

File 1

ToolFile Size
Initial Filesize26557472
zip26514031
gzip26513892
bzip226639209

File 2

ToolFile Size
Initial Filesize195629144
zip193951631
gzip193951493
bzip2194834876

Although the effects were minimal, the gzip compression comes out on top and bzip2 comes in last. 

Complete Folder Test

This time, the test is run on a folder full of images, documents, spreadsheets, videos, audio files, executables, and other different file formats.

Default Compression

ToolFile SizeTime Taken
Initial File13330841600
zip13031777781 minute 10 seconds
gzip13031776371 minute 35 seconds
bzip213092349476 minutes 5 seconds

Maximum Compression

ToolFile SizeTime Taken
Initial File13330841600
zip13031078941 minute 10 seconds
gzip13031077531 minute 35 seconds
bzip213092349476 minutes 10 seconds

Fastest Compression

ToolFile SizeTime Taken
Initial File13330841600
zip13041639431 minute 0 seconds
gzip13041638021 minute 15 seconds
bzip213135575956 minutes 10 seconds

Based on the final test, it is clear that bzip2 is not as useful as the other two compression tools. It takes longer to compress the files, and the final file size is larger than the other two tools.

The difference between zip and gzip is negligible, and while gzip generally comes out on top, the zip format is more common across different operating systems.

The Verdict

Use either zip or gzip as your Linux file compression tool. Maybe bzip2 has had its day and needs to be confined to history.