Commands.page Logo

How to Compress Directory with Deflate Zip on Ubuntu

This article provides a concise guide on compressing a directory within the Ubuntu operating system using the zip utility and the deflate algorithm. You will learn the specific terminal commands required to create a compressed archive recursively while maximizing compression efficiency. The steps below ensure your folders are archived correctly for storage or transfer.

Prerequisites

Ensure the zip utility is installed on your Ubuntu system. Most installations include it by default, but you can install it using the following command if necessary:

sudo apt update
sudo apt install zip

Compression Command

To compress a directory using the deflate method, open your terminal and navigate to the parent folder containing the directory you wish to archive. Execute the following command:

zip -r -9 archive_name.zip directory_name

Understanding the Flags

Verifying the Archive

Once the command completes, you can verify the contents and compression method using the unzip utility. Run the following command to list the contents and confirm the deflation method was applied:

unzip -l archive_name.zip

The output will display the file list and the method used, which should appear as Deflate alongside the compression percentage.