(Last Updated On: June 11, 2018)

Zip is a Linux/Unix compression and file packaging utility. Zip is used to compress files/directories while its companion program (unzip) is used to unpack the zip packages. Both programs can work with archives produced by PKZIP. With the recent releases of zip, it has support for bzip2 compression if the bzip2 library is was included during zip compilation.

Zip compression Levels

Compression levels regulate the speed of compression. Tthe total number of zip compression levels is 10 – (0-9), where -0 indicates no compression (store all files), -1 indicates the fastest compression speed (less compression) and -9 indicates the slowest compression speed (optimal compression, ignores the suffix list).

The default compression level is -6.

Let’s consider an example using highest zip compression level -9. To create a zip file for ~/Desktop directory run:

$ du -sh Desktop 
2.3M Desktop

$ zip -9 desktop.zip Desktop 
adding: Desktop/ (stored 0%)

$ du -sh desktop.zip 
4.0K desktop.zip

To use any other compression level, replace -9 with any of  (-0, -1, -2, -3, -4, -5, -6, -7, -8)