Run unzip file.zip. That's it. The archive extracts into your current working directory, folder structure intact.
unzip file.zip
Need it somewhere else? Add -d and a path:
unzip file.zip -d /var/www/html
Everything below is the stuff you'll actually need once the basic command isn't enough โ listing contents first, skipping overwrites, password prompts, and the errors that trip people up on fresh servers.
To prevent various sorts of theft or destruction, practically all files, including documents and media assets, are transferred in the zip format. Additionally, a password can be specified to prevent unauthorized access to the files, preserving the privacy of the contents. Even still, working with these kinds of files presents several challenges for novice users, those who lack sufficient computer literacy, and those without an IT background. To help you better understand the compression process, it's also important to learn how to zip files in Linux. For a comprehensive guide on creating zip files, check out our detailed tutorial on how to zip a file in Linux.

โ๏ธ What Is the unzip Command in Linux?
unzip is a small command-line utility that reads .zip archives and writes the files back out to disk. It handles nested folders, preserves relative paths, and can extract selectively instead of dumping the whole thing.
One important limit: it only speaks ZIP. A .tar.gz file needs tar -xzf. A .rar needs unrar. I've watched plenty of people run unzip backup.tar.gz and get a cryptic error, then assume the file's corrupt. It isn't โ wrong tool.
๐ง Prerequisites Before Unzipping Files in Linux
You need the unzip package installed on your computer to open a zip archive file. Most current Linux distributions already support unzip, but it doesn't hurt to double-check now to avoid unpleasant surprises later.
Check whether unzip is installed
Use this command in a terminal:
unzip --version
If you get a version banner, you're good. If you get unzip: command not found, install it. Desktop distros usually ship it. Minimal server images โ Ubuntu Server, Rocky, Debian netinstall, most VPS templates โ often don't.

How to install unzip on Ubuntu, Debian, CentOS, Fedora, Arch, and openSUSE
Pick the line that matches your package manager:
sudo apt install unzip # Ubuntu / Debian
sudo dnf install unzip # Fedora / RHEL 8+ / AlmaLinux / Rocky
sudo yum install unzip # CentOS 7 and older
sudo pacman -S unzip # Arch / Manjaro
sudo zypper install unzip # openSUSE
On Debian-based systems run sudo apt update first if the package index is stale. Takes two seconds and saves a confusing 404.

Once you have confirmed that your system supports unzip, you can unzip files in Linux. You can also move the unzipped files to a different directory using the mv command. For more details on how to move files in Linux, check out our guide on how to move files in Linux.

๐ป How to Unzip a File in Linux Using the Command Line
The unzip command is quite easy to use. Use the following command in the directory where the zip file is located:
Extract a ZIP file in the current directory
unzip zipped_file.zip
Output scrolls past showing each inflating: line. Files land relative to wherever you are, so cd to the right place before you run it.
Extract a ZIP file to a specific directory
Instead of navigating to the directory, you can also specify the path of the zip file. In the output, you'll find extracted files:
unzip metallic-container.zip -d my_zip
Archive: metallic-container.zip
inflating: my_zip/625993-PNZP34-678.jpg
inflating: my_zip/License free.txt
inflating: my_zip/License premium.txt
unzip creates the target directory if it doesn't exist, assuming you have write permission. This is the flag I use most on servers โ it keeps deployments from spraying files into /root by accident.

This command appears to be extremely practical overall. If the user uses the command above carelessly, he may occasionally get into a bigger issue. This command's main drawback is that it frequently extracts the whole contents of the selected zip file into the current directory or folder, which is undesirable, at least in some circumstances.
List ZIP contents without extracting
unzip -l archive.zip
You get a table of file names, sizes, and timestamps. Do this before every extraction you didn't create yourself. Some archives have a proper top-level folder; others are "tarbombs" that scatter 200 loose files into your current directory.

Extract only specific files or folders
Name the file you want:
unzip archive.zip document.txt
Or grab a whole directory with a quoted wildcard:
unzip archive.zip 'images/*'
Quote the pattern. If you don't, your shell expands it before unzip ever sees it, and you'll get "caution: filename not matched."
Exclude files during extraction
Use the -x option and a list of archive files you want to stop extracting, separated by spaces, to prevent particular files or directories from being extracted:
unzip archive.zip -x "*.txt"
Handy for pulling a site backup while skipping logs, or extracting a theme without the bundled documentation.
Overwrite existing files or skip them
By default unzip stops and asks you about every conflict, one at a time. That's fine for three files and miserable for three thousand.
unzip -o archive.zip # overwrite everything, no prompts
unzip -n archive.zip # never overwrite, keep existing files
Use -o when the archive is the source of truth. Use -n when your local changes matter more. And run the command without either flag if you genuinely want to decide case by case โ the prompt offers [y]es, [n]o, [A]ll, [N]one, [r]ename.
Unzip multiple ZIP files at once
unzip '*.zip'
That dumps everything into one directory, which gets messy fast. I prefer giving each archive its own folder:
for f in *.zip; do unzip "$f" -d "${f%.zip}"; done
Run unzip quietly
unzip -q archive.zip
Suppresses the per-file output. Useful inside cron jobs and deploy scripts where you only care about the exit code. Add a second -q (-qq) to silence it almost entirely.
Test an archive before extracting
unzip -t archive.zip
Verifies CRC checksums without writing a single byte. Worth running on any large download before you commit disk space to it.

Unzip to a specific directory
The issue above can be easily avoided by unzipping the target file to a separate directory rather than extracting it into the current directory.
In this manner, the directory chosen will house all of our extracted files. It will also take care of it by establishing the directory with the provided label if the user-specified directory is not there in some cases.
The steps below can be used to unzip a zipped file to a specific folder or directory:
- From the terminal, go to the directory where the compressed or zipped file is located.
- When you've arrived at that directory, enter this command into the terminal:
unzip zipped_file.zip -d unzipped_directory - The zipped file's whole contents will now be extracted to the unzipped directory.
๐ Useful unzip Options Explained
| Option | Description | Example |
| -d | Specifies the directory where files will be extracted. | unzip file.zip -d /path/to/directory |
| -x | Excludes specific files from extraction. | unzip file.zip -x "*.txt" |
| -P | Provides a password for encrypted zip files. | unzip -P password file.zip |
| -l | Lists the contents of the zip file without extracting. | unzip -l file.zip |
| -q | Runs the unzip command quietly (no output). | unzip -q file.zip |
| -o | Overwrites existing files without prompting. | unzip -o file.zip |
| -n | Never overwrites existing files. | unzip -n file.zip |
| -t | Tests archive integrity without extracting. | unzip -t file.zip |
To avoid cluttering your directory with unwanted files, you may want to use the find command in Linux to locate specific files within the extracted contents. You can learn more about using the find command effectively in our guide on how to find files in Linux.

๐ How to Unzip Password-Protected ZIP Files in Linux Safely
Just run the normal command. When unzip hits an encrypted entry, it prompts:
unzip secure.zip
Type the password, hit Enter, done. Nothing gets recorded anywhere. If the ZIP file is protected with encryption, unzip will request the password.
There's also -P yourpassword, which passes the password inline. Technically it works. But the password goes straight into ~/.bash_history and is visible to anyone running ps on that machine at the time. On a shared box or a VPS with multiple users, that's a real leak โ not a theoretical one. Use the interactive prompt unless you're scripting, and if you must script it, pull the secret from a file with restricted permissions instead.
Run the unzip command with the -P option and the password to unlock a password-protected file:
unzip -P PasswOrd filename.zip
Password input on the command line is unsafe and ought to be avoided. Extracting the file normally without entering the password is a more secure alternative.
๐ฅ๏ธ How to Unzip Files in Linux Using the GUI
If you use desktop Linux, visiting the terminal is not always necessary. Users of this strategy, especially beginners, will find it incredibly straightforward. It simply appears like the window's zip file extraction process. Follow the guidelines below for unzipping files in Linux using the graphical user interface.
Extract Here in your file manager
First, go to the folder containing your zip file using the file manager. The option "Extract Here" will appear when you right-click the file. Choose it. GNOME Files (Nautilus) and KDE's Dolphin both offer it, and both create a subfolder named after the archive โ no tarbomb risk.
The "Extract Here" option, in contrast to the unzip command, creates a folder with the same name as the zipped file and extracts all of the contents of the compressed files into this newly created folder.
Extract To another folder
You can also select the folder to which you would like to extract the files by choosing the "Extract To" option. Dolphin labels this Extract archive toโฆ; the behaviour is the same.

๐๏ธ How to Unzip Files in Linux Using Archive Manager
Many Linux distributions include Archive Manager as a default installation, providing a quick and simple way to unzip files in Linux.
First, navigate to the zip file's directory by opening the Files app. Then, select the "Open With Archive Manager" option by right-clicking the file. The zip file's contents will be opened by Archive Manager and seen there. To extract the contents into the current directory, select "Extract" from the menu bar.
Double-click the archive to open it in Archive Manager. You can browse the contents, drag out individual files, or hit Extract for the lot. It's the graphical equivalent of unzip -l followed by selective extraction.

๐จ Common unzip Errors and How to Fix Them
unzip: command not found
The package isn't installed. Run the install command for your distro from the prerequisites section above. This is by far the most common issue on fresh VPS builds.
Permission denied
You can't write to the target directory. Either extract somewhere you own (-d ~/tmp) or fix ownership with sudo chown -R $USER:$USER /path. Reaching for sudo unzip works but leaves root-owned files behind, which causes problems later.
Incorrect password
You'll see incorrect password or skipping: ... incorrect password. Watch for a trailing space when pasting, and remember ZIP passwords are case-sensitive. Some archives use AES encryption that classic unzip can't read โ try 7z x archive.zip in that case.
End-of-central-directory signature not found
The file is truncated, corrupt, or isn't actually a ZIP. Check its size against the source, run file archive.zip to confirm the format, and re-download if needed. Multipart archives need to be joined before extraction.
Endless overwrite prompts
Answer A for all, or restart with -o to overwrite silently and -n to skip.
๐ ZIP vs TAR.GZ vs RAR in Linux
| Format | Extract command | Tool needed |
.zip |
unzip file.zip |
unzip |
.tar.gz / .tgz |
tar -xzf file.tar.gz |
tar (preinstalled) |
.tar.bz2 |
tar -xjf file.tar.bz2 |
tar |
.rar |
unrar x file.rar |
unrar |
.7z |
7z x file.7z |
p7zip |
ZIP compresses each file separately, so selective extraction is fast. TAR.GZ compresses the whole stream, giving better ratios but requiring a full pass to pull one file. If you want the deeper breakdown, see our guide on extracting tar archives in Linux and the difference between ZIP and tar.gz.
๐ก๏ธ Best Practices for Safely Extracting ZIP Files
- Inspect first.
unzip -ltakes one second and tells you exactly what's about to hit your filesystem. - Don't extract untrusted archives as root. An archive containing paths like
../../etc/can write outside your target directory. Modernunzipstrips leading slashes, but why hand it root anyway? - Extract to an isolated folder.
mkdir tmp-extract && unzip file.zip -d tmp-extract, then move what you need with the techniques from our guide on moving files in Linux. - Keep passwords out of your shell history. Skip
-Pon interactive sessions. - Watch for odd filenames โ leading dashes, absolute paths, unusual Unicode. All are red flags.
๐ฏ Conclusion
One of the most typical and well-liked methods for producing compressed archive files is Zip. It was developed in 1989, making it one of the older archive file formats. You'll frequently encounter a zip file because it is so commonly used. By following one of the mentioned methods, you will have no problem unzipping files in Linux.
The command you'll use 90% of the time is unzip file.zip, and the flag you'll reach for next is -d. Add -l before extracting anything you didn't build yourself, and remember -o and -n when prompts start piling up.
Next up: learn to create a ZIP archive in Linux, brush up on essential Linux commands for beginners, or get faster at finding extracted files once they're on disk. And if you want a dedicated environment to practice all of this, buy Linux VPS server and run every command in this guide on your own machine.
Additionally, if you're looking to explore more about working with files in Linux, check out our guide on how to create files in Linux to expand your knowledge and enhance your Linux skills.
For businesses or users seeking enhanced performance and control, Linux Dedicated Servers provide a reliable environment to manage your directories and files efficiently. Learn more about their benefits and why they're a popular choice in the hosting world.


Leave A Comment