Compression saves space by compressing data while archiving simplifies data transfer by merging several files or folders into a single file. For example, if we need to send five files over the internet, each of which is 100 MB, sending each file one by one could take longer. It would be much faster to copy the files if they are compressed to a size of up to 50 MB and then archived in a single file. unzip is used to retrieve and decompress zipped files. This guide covers installing unzip, extracting to different directories, skipping or forcing overwrites, checking archives before extraction, and fixing common errors.
Tested on Ubuntu 24.04 and Debian 12 with Info-ZIP UnZip 6.0. The commands work the same way on RHEL-family distros and Arch.
⚡ Quick Answer: The Linux Command to Unzip a .zip File
To unzip a file in Linux, open a terminal, go to the folder that holds the archive, and run:
unzip file.zipThat's it. The command extracts everything into your current directory and keeps the folder structure stored in the archive.
🔍 What Is the unzip Command in Linux?
unzip is the Info-ZIP utility for ZIP archives. It can do three things: extract files, list what's inside an archive, and test an archive's integrity. Most people only use the first one, but the other two save a lot more time. It belongs to the same family as most of the everyday tools in our basic Linux commands cheat sheet.
One thing about ownership: ZIP files usually come from Windows or macOS, and they don't carry Linux ownership data. Extracted files belong to whoever ran the command, and permissions follow your umask unless the archive stored Unix permission bits. If a web server suddenly can't read the extracted files, this is usually why.
📦 How to Install Zip and Unzip Utility
By default, Ubuntu systems come with zip and unzip packages, but minimal server and cloud images often leave unzip out. You can install it if not present in your operating system. Open Terminal with Ctrl+Alt+T and use the command for your distro.
Install unzip on Ubuntu and Debian
sudo apt install zip
sudo apt install unzipOlder guides use sudo apt-get install unzip. It does the same job. For a Ubuntu-specific walkthrough with screenshots, see our guide on how to unzip a ZIP file on Ubuntu.
Install unzip on RHEL, CentOS, AlmaLinux, and Rocky Linux
sudo dnf install unzip
# CentOS 7 and older:
sudo yum install unzipOn a CentOS 7 server the flow is slightly different (yum cache, yum-based install) — our CentOS 7 zip and unzip guide walks through it step by step.
Install unzip on Fedora
sudo dnf install unzipInstall unzip on Arch Linux
sudo pacman -S unzipYou will need to extract ZIP files in Linux in the following circumstances:
- Since zipping reduces the file size, it saves disk space.
- Using email to forward huge files
- Increasing the speed of uploading or copying files
- In order to conserve bandwidth
To simplify your Linux file size management, read How to Find File Size in Linux.
🛠️ Basic unzip Command Syntax
unzip [options] archive.zip [files] [-x excluded] [-d destination]These are the six options you'll use most of the time:
| Option | What it does | Example |
-d |
Extract to a specific directory | unzip archive.zip -d /path |
-l |
List contents without extracting | unzip -l archive.zip |
-t |
Test archive integrity | unzip -t archive.zip |
-n |
Never overwrite existing files | unzip -n archive.zip |
-o |
Overwrite without prompting | unzip -o archive.zip |
-x |
Exclude files or patterns | unzip archive.zip -x "*.log" |
📂 How to Unzip in Linux? [Linux Unzip Command]
When used without any options, the unzip command removes all files from the designated ZIP folder to the current directory in its most basic form. Let's presume you downloaded an installation ZIP file as an example. Simply execute the following command to unzip this file to the current directory:
unzip installation.zipZIP archives do not support Linux-style ownership details. The person who executes the command owns the collected data. The folder where you're extracting the archive must have write permissions.
The output of the unzip Linux command
Unzip prints the names of all the files downloaded by default, as well as a list when it's finished. To prevent these messages from being printed, use the -q option.
unzip -q filename.zipHow to Unzip a ZIP file to a New Directory?
Using the -d option to unzip a ZIP file to a separate directory from the present one:
unzip filename.zip -d /path/to/directoryIf the destination doesn't exist, unzip creates it. To unzip an installation folder file.zip to the /var/xyz/folder, for example, run the below command:
sudo unzip installation.zip -d /var/xyzWe're using sudo above because the user we're logging in as normally doesn't have write access to the /var/xyz directory. When you use sudo to decompress ZIP data, the root owns the extracted files and folders.
How to Unzip multiple files?
Regular expressions should be used to balance different files. If you have several ZIP files in your current working directory, you can unzip all of them with only one unzip command:
unzip '*.zip'Keep the *.zip in single quotes. Without them, the shell expands the wildcard into unzip a.zip b.zip c.zip, and unzip reads that as "extract b.zip and c.zip from inside a.zip."
🔎 How to List ZIP File Contents Without Extracting
Using the -l option to list the contents of a ZIP file:
unzip -l archive.zipYou'll see each file's size, date, and path, plus a total at the bottom. This is useful on any archive you didn't create. It tells you whether there's a top-level folder and how much disk space you'll need.
✅ How to Test a ZIP Archive Before Extracting
Use -t to check archive integrity:
unzip -t archive.zipThis checks the CRC of every file without writing anything to disk. If the output ends with "No errors detected," you're fine. Use it after large downloads, interrupted transfers, or FTP uploads that might have used ASCII mode.
⚠️ Unzip Command Will Overwrite the Existing Files
Let's pretend you've already unzipped a ZIP file, and you're repeating the process. By default, unzip stops at every conflict and asks: [y]es, [n]o, [A]ll, [N]one, [r]ename. That's fine for one or two files but painful in scripts.
Output:
Archive: latest.zip
replace wordpress/xmlrpc.php? [y]es, [n]o, [A]ll, [N]one, [r]ename:
Using the -o method if you want to erase current files without prompting:
unzip -o filename.zipWarning: -o replaces files without asking. Run it in the wrong directory and your edited config files are gone. Back up first, or check what's coming with -l.
Unzip Command Without Overwriting the Existing Files
Assume you've already unzipped a ZIP file and modified certain files, but you've also erased a few files by mistake. You want to retain the updates and recover the files removed from the ZIP directory. Using -n forces unzip to skip the extraction of a file that already exists:
unzip -n filename.zip📄 How to Extract Specific Files From a ZIP Archive
Extract One File
unzip archive.zip docs/readme.txtUse the full path exactly as unzip -l shows it.
Extract One Folder
unzip archive.zip "images/*"Exclude Files or Folders During Extraction
Using the -x option accompanied by a space-separated list of archive files you wish to remove from being extracted:
unzip filename.zip -x file1-to-exclude file2-to-excludeExcept for the .git directory, we remove all files and folders from the ZIP folder in the following example:
unzip filename.zip -x "*.git/*"Quote every pattern so the shell doesn't expand it first. If a name has spaces, wrap it in quotes too: "My Files/report.pdf".
🔐 How to Unzip Password-Protected ZIP Files
Interactive Password Prompt
Just run the normal command:
unzip secret.zipunzip notices the encryption and asks for the password. What you type doesn't appear on screen and isn't saved anywhere.
Output:
Archive: filename.zip
[filename.zip] file.txt password:
Why -P Should Be Avoided When Possible
Yes, unzip -P mypassword secret.zip works, but the password ends up in your shell history, and other users on the system can see it in process listings like ps. On a shared VPS, that's a real risk. Only use -P in throwaway environments. Also, Info-ZIP's unzip can't handle AES-encrypted archives. Use 7z x for those.
🩺 Common unzip Errors and How to Fix Them
unzip: command not found
The package isn't installed. Use the install command for your distro from the section above.
Permission denied
You can't write to the destination folder. Check with ls -ld /target/dir, then either extract somewhere you own or use sudo for system paths. If extracted files won't open, fix their permissions with chmod and their ownership with chown. On a server, this is usually a permissions problem you want to solve once and forget — a Rocky Linux VPS ships with sensible defaults and SELinux enforcing from day one.
Archive appears corrupted
"End-of-central-directory signature not found" means one of three things: the download didn't finish, it isn't actually a ZIP file, or it's one part of a split archive. Run file archive.zip to see what it really is, download it again, and check it with unzip -t. Split archives need to be joined first, for example with zip -s 0 split.zip --out joined.zip.
Files already exist
Use -n to skip existing files, -o to replace them, or -d to extract into a clean directory.
⚖️ unzip vs tar vs 7z in Linux
A lot of "how do I decompress a file" problems come down to using the wrong tool. Pick the one that matches the file extension:
| Tool | Best for | Example |
| unzip | .zip files |
unzip file.zip |
| tar | .tar, .tar.gz, .tar.xz |
tar -xf file.tar.gz |
| 7z | .7z, AES-encrypted ZIPs, mixed formats |
7z x file.7z |
To create archives, use the companion zip command: zip -r backup.zip folder/. For a deeper dive into the creation side, see our zip command guide, and if you're working with tarballs, our tar.gz extraction guide covers that side. On Ubuntu specifically, our Ubuntu zip guide covers both the CLI and GNOME GUI methods.
💡 Best Practices When Extracting ZIP Files on Linux
- Look inside with
-lbefore extracting archives from unknown sources. - Run
-ton large downloads before deploying anything from them. - Extract into a fresh directory with
-dso you don't clutter your working directory. - Don't extract as root unless you have to.
- Type passwords at the prompt instead of using
-P. - After extracting, check the result with
ls -laanddu -sh.
If you're still building up your command-line fluency, our 90-day Linux learning roadmap covers the fundamentals in order. And when you're ready to practice on a real machine, a Linux hosting plan with full root access is the fastest way to build the habit.
🎯 Conclusion
The unzip command lists and extracts compressed ZIP files. The zip command creates them. When someone sends you a ZIP file, you can unzip it in Linux to see the contents. This guide covered the six options that matter most, how to extract to a different directory, how to skip or force overwrites, how to check archives before extraction, and how to fix common errors.
Practicing on a real server? A Linux VPS gives you full root access and NVMe storage — the fastest way to get comfortable with the unzip command on a production-style system.
People are also reading: