How to Unzip a File in Linux

While the Linux ecosystem traditionally relies on .tar.gz archives for distributing software, the rest of the computing world (Windows and macOS) relies almost entirely on the ubiquitous .zip format. Because of this, it is highly likely that a colleague or a web server will eventually send you a zip file, and you must know how to extract its contents using the Linux command line.

Fortunately, extracting a zip archive is one of the simplest tasks you can perform in the terminal, provided you have the correct utility installed.

Step 1: Install the Unzip Utility

The biggest hurdle beginners face is assuming that Linux can open zip files out of the box. Unlike Windows, which has zip functionality baked directly into the operating system, many Linux distributions do not install the required software by default.

If you try to run the command and the terminal prints unzip: command not found, you must install it first.

  • On Ubuntu, Debian, or Linux Mint:
    sudo apt update
    sudo apt install unzip
  • On Fedora, CentOS, or Red Hat:
    sudo dnf install unzip

Step 2: Unzip a File into the Current Directory

Once the utility is installed, extracting a file is incredibly straightforward. By default, the unzip command will rip open the archive and dump all of the files and folders directly into whatever directory you are currently standing in.

  1. Use the cd command to navigate to the folder where your zip file is located (e.g., cd ~/Downloads).
  2. Type the unzip command followed by the exact name of the file:

unzip project_files.zip

The terminal will rapidly print a list (saying “inflating: filename.txt”) as it extracts every single item from the archive and drops it into your Downloads folder.

Step 3: Unzip a File into a Specific Directory (-d Flag)

Dumping files directly into your current directory can be incredibly messy. If the zip file contains 500 loose images and you extract it directly into your main Downloads folder, you will completely clutter your workspace.

The best practice is to extract the contents into a dedicated folder. You can do this by using the -d (destination) flag.

unzip project_files.zip -d /path/to/new_folder/

For example, if you want to extract the files into a brand new folder on your desktop called “ExtractedProject”, you would type:

unzip project_files.zip -d ~/Desktop/ExtractedProject/

The unzip utility is smart enough to realize that the “ExtractedProject” folder doesn’t exist yet. It will automatically create the brand new folder and neatly place all 500 images safely inside it, keeping your file system clean and organized.

Advanced Tip: How to View the Contents Without Extracting (-l Flag)

If you downloaded a massive 5GB zip file from a suspicious website, you might not want to instantly extract it onto your hard drive. You can command Linux to simply look inside the archive and print a list of the contents, without actually extracting anything.

To do this, use the -l (list) flag.

unzip -l mysterious_file.zip

The terminal will print a clean table showing the file names, file sizes, and timestamps of everything hidden inside the archive, allowing you to verify its safety before committing to an extraction.

Get the best tech tips delivered straight to your inbox.

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