The basic command to extract a zip file
To extract a zip file in Linux, use the unzip command followed by the filename. Open a terminal, navigate to the folder containing your zip file, and type unzip filename.zip. The files will extract into the current directory.
If the zip file is in a different location, include the full path: unzip /path/to/filename.zip. Linux will create any folders that were inside the zip and place all files in their original structure.
Most Linux distributions come with unzip pre-installed. If you get a "command not found" error, you can install it through your package manager — on Ubuntu or Debian, run sudo apt install unzip; on Fedora or RHEL, run sudo dnf install unzip.
Key Takeaways
- The unzip filename.zip command extracts all files from a zip archive into your current directory.
- Use unzip -l filename.zip to preview the contents before extracting anything.
- Extract to a specific folder with unzip filename.zip -d /path/to/folder to keep your files organized.
- The -o flag overwrites existing files without asking, and -n skips files that already exist.
- Graphical file managers like Nautilus and Dolphin can also extract zip files with a right-click menu.
Preview what's inside before extracting
Before extracting a zip file, you may want to see what it contains. Use unzip -l filename.zip to list all files and folders inside without extracting them. This shows the file names, sizes, and the folder structure.
If you want more detail, including compression ratios and dates, use unzip -lv filename.zip for a verbose listing. This is useful when you're not sure whether a zip file will create a single folder or dump dozens of files into your current directory.
Extract to a specific folder instead of the current directory
By default, unzip places files in whatever folder you're currently in. To extract into a different location, use the -d flag: unzip filename.zip -d /path/to/destination. Linux will create the destination folder if it doesn't exist.
This is especially useful when you download a zip file to your Downloads folder but want the contents in a project folder. For example, unzip ~/Downloads/project.zip -d ~/projects/ extracts the archive into your projects directory without cluttering Downloads.
Handle files that already exist
If you extract a zip file and some files already exist in that location, unzip will ask what you want to do. You have three options: overwrite the existing file, skip it, or rename the new one. Typing your choice for each file can be tedious with large archives.
To skip all existing files automatically, use unzip -n filename.zip. To overwrite all existing files without prompting, use unzip -o filename.zip. Choose based on whether you want to keep the old versions or replace them entirely.
Extract only specific files from a zip
You don't have to extract everything. To pull out only certain files, list them after the filename: unzip filename.zip file1.txt file2.txt. You can also use wildcards — unzip filename.zip "*.txt" extracts only text files, and unzip filename.zip "folder/*" extracts only files from a specific folder inside the zip.
Wildcards must be in quotes so the shell doesn't interpret them before unzip sees them. This approach is handy when a zip contains hundreds of files but you only need a few.
Use a graphical file manager instead
If you prefer not to use the terminal, most Linux desktop environments include a file manager that handles zip files. In GNOME (Ubuntu), right-click the zip file and select "Extract Here" or "Extract To". In KDE (Fedora, Kubuntu), right-click and choose "Extract Archive Here" or pick a destination folder.
File managers typically create a new folder with the zip's name if the archive contains multiple items, or extract files directly if it contains only one. This method is slower for large batches of files but requires no command-line knowledge.
Frequently Asked Questions
What if unzip says "command not found"?
The unzip tool isn't installed. On Ubuntu or Debian, open a terminal and run sudo apt install unzip. On Fedora, CentOS, or RHEL, run sudo dnf install unzip. On Arch, run sudo pacman -S unzip. After installation, the unzip command will work.
Can I extract a zip file that's password-protected?
Yes. Run unzip filename.zip and unzip will prompt you for the password before extracting. If you want to provide the password in the command itself, use unzip -P password filename.zip, though this leaves the password visible in your terminal history.
How do I extract 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 the current directory into that same directory. To extract each into its own folder, use for file in *.zip; do unzip "$file" -d "${file%.zip}"; done.
What's the difference between unzip and other tools like tar?
Unzip handles .zip files specifically. Linux also uses tar for .tar, .tar.gz, and .tar.bz2 files — these are common for source code and backups. Zip is more common on Windows and for sharing files across different systems, while tar is standard for Linux software distribution.
Can I see the extraction progress for large files?
By default, unzip shows each filename as it extracts. For a simpler output, use unzip -q filename.zip to run quietly with no output. There's no built-in progress bar, but the quiet mode makes it clear the command is still running without printing every file name.