The .zip file format is the absolute universal standard for compressing massive folders full of text documents, high-resolution photographs, or complex software source code into a single, easily downloadable package. While graphical desktop operating systems allow you to simply double-click these archives to extract them, manipulating a ZIP file on a headless Linux server requires a specific, dedicated terminal command. The tool for this job is the aptly named and highly efficient unzip command.
Step 1: Installing the Unzip Utility
Surprisingly, the unzip utility is not always installed by default on minimal server installations. If the command fails, you must install it first.
- Open your terminal application or connect to your server via SSH.
- If you are using a Debian or Ubuntu-based system, type the following command to install the tool:
sudo apt update && sudo apt install unzip
Step 2: Extracting the ZIP File
Once the utility is installed, extracting the contents takes only a fraction of a second.
- Navigate to the directory containing your archive using the
cdcommand (e.g.,cd /Downloads). - To extract the contents of the archive perfectly into your current directory, type the following command and press Enter:
unzip filename.zip
The terminal will instantly flood with output as it rapidly unpacks and lists every single file contained within the archive.
Step 3: Extracting to a Specific Directory
If you extract a massive archive directly into your current folder, it will create a massive mess of files. If you want to keep your workspace clean and extract the contents into a completely new, separate destination folder, you must use the -d (destination) flag.
- Type the following command:
unzip filename.zip -d /path/to/new/folder
The unzip utility will automatically create the new destination folder (if it doesn’t already exist) and neatly deposit all the extracted files inside it, leaving your current directory perfectly organized.