The basic command to unzip a file
To unzip a file in Linux, use the unzip command followed by the filename. Open your terminal, navigate to the folder where the .zip file is located, and type unzip filename.zip. The command extracts all files and folders from the archive into your current directory.
If the .zip file is in a different location, include the full path: unzip /path/to/filename.zip. Linux will show you each file as it extracts, then display a summary when finished.
Most Linux distributions come with unzip pre-installed. If you get a "command not found" error, you can install it using your package manager — on Ubuntu or Debian, run sudo apt install unzip; on Fedora or RHEL, run sudo dnf install unzip.
Key Takeaways
- The command unzip filename.zip extracts all contents into your current directory.
- Use unzip -l filename.zip to see what is inside a .zip file before extracting it.
- Extract to a specific folder with unzip filename.zip -d /path/to/folder instead of cluttering your current directory.
- Use unzip -o filename.zip to overwrite existing files without being asked, or unzip -n filename.zip to skip files that already exist.
Preview the contents before extracting
Before you unzip, it is often useful to see what files are inside. Use unzip -l filename.zip to list everything without extracting. This shows the filename, size, and date for each file inside the archive.
If you want more detail, use unzip -lh filename.zip to display file sizes in a human-readable format (KB, MB) instead of raw bytes. This helps you check whether the archive contains what you expect and how much disk space it will need.
Extract to a specific folder
By default, unzip puts all files into your current directory, which can create clutter. To extract into a specific folder instead, use the -d flag: unzip filename.zip -d /path/to/destination.
If the destination folder does not exist yet, unzip will create it for you. For example, unzip archive.zip -d ~/Downloads/extracted puts everything into a new folder called extracted inside your Downloads directory.
Handle files that already exist
If you unzip an archive and some files already exist in the destination, unzip will ask whether to overwrite each one. To skip this prompt and keep your existing files, use unzip -n filename.zip. The -n flag means "never overwrite" — any file that already exists is left alone.
To do the opposite — overwrite everything without being asked — use unzip -o filename.zip. The -o flag means "overwrite" and is useful when you want to replace an older version of the extracted files with a newer one from the archive.
Work with password-protected archives
Some .zip files are encrypted with a password. When you try to unzip one, the terminal will prompt you to enter the password before extraction begins. Type it in (the characters will not display on screen) and press Enter.
If you want to provide the password in the command itself instead of being prompted, use unzip -P password filename.zip. Be aware that this stores the password in your command history, so use this method only on your own machine and only when security is not a concern.
Extract a single file from an archive
You do not have to extract the entire .zip file. To pull out just one file, type unzip filename.zip path/to/specific/file. Replace path/to/specific/file with the exact path shown when you list the archive contents with unzip -l.
You can also extract multiple specific files by listing them one after another: unzip filename.zip file1.txt file2.txt file3.txt. This is faster than extracting everything when you only need a few items.
Troubleshoot common issues
If you see "unzip: command not found", the unzip tool is not installed. Install it using your package manager as described in the first section. If extraction seems to hang or freeze, the archive may be corrupted — try listing its contents with unzip -t filename.zip to test whether the file is readable.
If extracted files have unusual permissions or ownership, use chmod or chown to fix them after extraction. For example, chmod 755 foldername makes a folder readable and executable by everyone, and chown username:groupname foldername changes who owns it.
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, .tar.gz, and .tar.bz2 files, which are more common in Linux. They are different archive formats with different commands — use unzip for .zip and tar for .tar files.
Can I unzip a file without using the terminal?
Yes. Most Linux desktop environments (GNOME, KDE, Xfce) include a file manager that can extract .zip files by right-clicking and selecting "Extract" or similar. This is simpler than the terminal if you only need to unzip once, but the command line is faster for repeated tasks or scripts.
How do I unzip multiple .zip files at once?
Use a loop in the terminal: for file in *.zip; do unzip "$file"; done. This extracts every .zip file in your current directory. To extract each one into its own folder, use for file in *.zip; do unzip "$file" -d "${file%.zip}"; done instead.
What does the -q flag do?
The -q flag runs unzip in quiet mode, suppressing the list of files as they are extracted. Use unzip -q filename.zip when you do not need to see the progress — useful in scripts or when you are extracting a very large archive and the output would be overwhelming.