How to Unzip a File in Linux

Because Linux relies heavily on the command line for package management and software installation, you will frequently find yourself downloading massive source code repositories or complex database backups directly from the internet via wget or curl. These files are almost always compressed into archives to save bandwidth.

While the older .tar.gz format is still incredibly popular in the Linux world, the universal .zip format is heavily used for cross-platform files. You cannot run a script or read a text document while it is still trapped inside a ZIP archive; you must extract the files using the unzip command.

Step 1: Install the unzip Utility

The biggest trap for beginners is assuming the unzip command is built into the Linux kernel. It is not. Many minimalist server distributions (like Ubuntu Server or Alpine) do not include it by default to save disk space.

If you type the command and the terminal throws an error stating bash: unzip: command not found, you must install it first.

  • On Debian/Ubuntu: Type sudo apt install unzip
  • On CentOS/RHEL: Type sudo yum install unzip
  • On Arch Linux: Type sudo pacman -S unzip

Step 2: Unzip a File (The Basic Command)

Once the utility is installed, extracting a file is incredibly simple.

  1. Open your terminal.
  2. Use the cd command to navigate to the exact folder where your ZIP file is currently sitting (e.g., cd ~/Downloads).
  3. Type the unzip command followed by the exact name of the file.

unzip project_files.zip

Press Enter. The terminal will instantly flood with text, listing every single file as it is violently ripped out of the archive. By default, Linux will dump all of these newly extracted files directly into your current directory, mingling them with whatever else was already in the folder.

Method 3: Extract Files to a Specific Directory

Dumping 500 unzipped configuration files directly into your main Downloads folder is a messy disaster. It is highly recommended that you force Linux to build a brand new, empty folder and place the extracted files safely inside it.

You can do this by appending the -d (destination) flag to the command, followed by the name of the new folder you want to create.

unzip project_files.zip -d /home/user/project_folder

If the folder project_folder does not exist, the unzip command will intelligently create it for you, and then safely inject the uncompressed files inside it, keeping your system perfectly organized.

Method 4: How to Peek Inside a ZIP File (Without Extracting)

If you download a sketchy ZIP file from the internet, you should never extract it blindly, as it could contain a malicious script. You can use the -l (list) flag to force Linux to peek inside the archive and print a table of contents to the terminal screen, without actually decompressing anything.

unzip -l mysterious_file.zip

The terminal will print the name, size, and date of every file hidden inside the archive, allowing you to safely inspect the contents before you commit to extracting it.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.