Which Is the Best Compression Tool for Linux?

Take a look at zip vs. gzip vs. bzip2

ZIP FILE CONCEPT

  cnythz / Getty Images 

The three most common file compression formats you're likely to encounter on Linux are zip, gzip and bzip2. Which one is most efficient depends on what you are planning to compress. We tested all three to find out which compression tool is fastest on Linux.

Information in this article applies to the Linux operating system.

Best Linux Compressing Tool for Windows Documents

For our first test, we compressed a document in the Microsoft DOCX format using each compression tool. Using the default settings, the results were as follows:

Format File Size
Initial file 12,202 bytes
zip 9,685 bytes
gzip 9.537 bytes
bzip2 10,109 bytes

Using the maximum compression settings on the same file delivered similar results:

Format File Size
Initial file 12,202 bytes
zip 9,677 bytes
gzip 9,530 bytes
bzip2 10,109 bytes

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. Gzip comes out on top in all categories, and bzip2 is the least effective.

Best Tool for Compressing Images

For the next test, we compressed images in the PNG, JPEG, bitmap, and GIF formats:

PNG File

Format File Size
Initial file 345,265 bytes
zip 345,399 bytes
gzip 345,247 bytes
bzip2 346,484 bytes

JPEG File

Format File Size
Initial file 44,340 bytes
zip 44,165 bytes
gzip 44,015 bytes
bzip2 44,281 bytes

Bitmap File

Format File Size
Initial file 3,113,334 bytes
zip 495,028 bytes
gzip 494,883 bytes
bzip2 397,569 bytes

GIF File

Format File Size
Initial file 6,164 bytes
zip 5,772 bytes
gzip 5,627 bytes
bzip2 6,051 bytes

Gzip came out on top again with one exception: the bitmap image. Bzip2 compression produced a slightly smaller file by about 100 KB.

In theory, JPEG files are already compressed, so trying to compress them could actually make them bigger.

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 we tested:

MP3 File 1

Format File Size
Initial file 5,278,905 bytes
zip 5,270,224 bytes
gzip 5,270,086 bytes
bzip2 5,270,491 bytes

MP3 File 2

Format File Size
Initial file 4,135,331 bytes
zip 4,126,138 bytes
gzip 4,126,000 bytes
bzip2 4,119,410 bytes

Best Tool For Compressing Video

For this test, two video files were compressed. 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

Format File Size
Initial file 731,908 bytes
zip 478,546 bytes
gzip 478,407 bytes
bzip2 478,042 bytes

FLV

Format File Size
Initial file 7,833,634 bytes
zip 4,339,169 bytes
gzip 4,339,030 bytes
bzip2 4,300,295 bytes

Bzip2 did the best job at compressing both formats, but the results were similar.

Best Tool for Compressing Executables

Because executable files are compiled code, it's no surprise that they don't compress well.

File 1

Format File Size
Initial file 26,557,472 bytes
zip 26,514,031 bytes
gzip 26,513,892 bytes
bzip2 26,639,209 bytes

File 2

Format File Size
Initial file 195,629,144 bytes
zip 193,951,631 bytes
gzip 193,951,493 bytes
bzip2 194,834,876 bytes

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

Complete Folder Test

Finally, we compressed a folder full of images, documents, spreadsheets, videos, audio files, executables, and other different file types. We used each format on three different compression settings:

Default Compression

Format File Size Time Taken
Initial file 1,333,084,160 bytes N/A
zip 1,303,177,778 bytes 1 minute, 10 seconds
gzip 1,303,177,637 bytes 1 minute, 35 seconds
bzip2 1,309,234,947 bytes 6 minutes, 5 seconds

Maximum Compression

Format File Size Time Taken
Initial file 1,333,084,160 bytes N/A
zip 1,303,107,894 bytes 1 minute, 10 seconds
gzip 1,303,107,753 bytes 1 minute, 35 seconds
bzip2 1,309,234,947 bytes 6 minutes, 10 seconds

Fastest Compression

Format File Size Time Taken
Initial file 1,333,084,160 bytes N/A
zip 1,304,163,943 bytes 1 minute, 0 seconds
gzip 1,304,163,802 bytes 1 minute, 15 seconds
bzip2 1,313,557,595 bytes 6 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.

Final Verdict

Use either zip or gzip as your Linux file compression tool. 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. While bzip2 can outperform both in rare instances, the benefits are minimal.