The basic command to unzip a file

To unzip a file in Linux, open your terminal and type unzip filename.zip, then press Enter. The files inside will extract to your current folder. That is the whole thing — Linux comes with the unzip tool built in, and it works without any setup or extra steps.

If you want the files to go into a specific folder instead of your current one, use unzip filename.zip -d /path/to/folder. The -d flag tells unzip where to put everything. If the folder does not exist yet, unzip will create it for you.

Key Takeaways

  • Type unzip filename.zip in your terminal to extract files to the current folder.
  • Use the -d flag to send files to a different folder: unzip filename.zip -d /path/to/folder.
  • If a file already exists in the destination, unzip will ask before overwriting it — type A to overwrite all, or N to skip each one.
  • You can list what is inside a zip file without extracting it by typing unzip -l filename.zip.

What to do if unzip is not installed

On most Linux systems, unzip comes pre-installed. If you type the command and get "command not found", you will need to install it through your package manager. On Ubuntu or Debian, type sudo apt install unzip. On Fedora or Red Hat, type sudo dnf install unzip. On Arch, type sudo pacman -S unzip.

After installation finishes, the unzip command will work the same way as described above. You only need to install it once per system.

Handling files that already exist

When you unzip a file, if something with the same name already exists in the destination folder, unzip will stop and ask what you want to do. You will see a prompt that says "replace filename? [y]es, [n]o, [A]ll, [N]one, [r]ename". Type A to overwrite all existing files without asking again, or N to skip all of them.

If you want to overwrite everything without being asked at all, add the -o flag: unzip -o filename.zip. If you want to rename files instead of overwriting, type r at each prompt and unzip will ask you for a new name.

Seeing what is inside before you extract

To look at the contents of a zip file without extracting anything, type unzip -l filename.zip. This shows you the file names, sizes, and dates inside. The -l flag means "list" — nothing gets written to disk.

If you want more detail, use unzip -lv filename.zip (the v stands for "verbose"). This shows compression ratio and other technical details. Both commands are safe to run on any zip file because they only read, they do not change anything.

Extracting only certain files from a zip

You do not have to extract everything. To pull out just one file, type unzip filename.zip specific-file.txt. To extract multiple specific files, list them all: unzip filename.zip file1.txt file2.txt file3.txt.

You can also use a pattern to match file names. For example, unzip filename.zip "*.txt" extracts only the text files. The quotes are important — without them, your terminal might try to match the pattern before unzip sees it. This is useful when a zip contains hundreds of files and you only need a few.

Working with nested folders inside the zip

When you unzip a file, any folders that were inside the zip are recreated in your destination. If the zip contains documents/reports/2024/file.txt, unzip will create that whole folder structure for you automatically.

If you want to flatten the structure and put all files directly in the destination folder (ignoring the internal folder layout), there is no built-in flag for that in unzip itself. You would need to extract normally and then move files manually, or use a different tool. For most cases, keeping the folder structure is what you want anyway.

Unzipping files with passwords

If a zip file is password-protected, unzip will ask you for the password when you run the command. Type unzip filename.zip and it will prompt you to enter the password before extracting. The password does not show on screen as you type — that is normal and intentional.

If you want to provide the password in the command itself (useful in scripts), use unzip -P password filename.zip. The -P flag takes the password as an argument. Be careful with this method — anyone who can see your terminal history or running processes will see the password in plain text.

Frequently Asked Questions

What is the difference between unzip and tar?

Unzip handles .zip files, which are common on Windows and the web. Tar handles .tar files, which are more common in Linux. They are different formats. If you have a .tar.gz file, you use tar, not unzip. If you have a .zip file, you use unzip.

Can I unzip a file to a folder that does not exist yet?

Yes. If you type unzip filename.zip -d /path/to/new/folder and that folder does not exist, unzip will create it and all parent folders automatically. You do not need to create the directory first.

How do I unzip multiple zip files at once?

Type unzip "*.zip" to extract all zip files in the current folder. The quotes are important. Each zip will extract to its own set of files — if two zips contain a file with the same name, unzip will ask which one to keep.

What does the error "End-of-central-directory signature not found" mean?

This means the zip file is corrupted or incomplete. The file may not have downloaded fully, or it was damaged. Try downloading it again. If the error persists, the original file may be broken.

Can I unzip a file without using the terminal?

Yes, if your desktop environment has a file manager (like Nautilus on GNOME or Dolphin on KDE), you can right-click the zip file and select "Extract" or "Extract Here". This does the same thing as the terminal command, just with a graphical interface.