Zip archives still show up everywhere, from project downloads and backups to file bundles shared across Windows and Linux systems. To unzip to another directory in Linux, use unzip archive.zip -d /path/to/destination. The same unzip command in Linux also lists archive contents, tests archive integrity, and skips files you do not want to extract.
unzip is already available on many desktop and server installations, but minimal images and containers sometimes leave it out. Most readers only need a quick availability check, the -d extraction pattern, and a short list of the errors that point to a bad path or the wrong archive format.
Understand the unzip Command
The unzip command extracts .zip archives from the terminal while preserving the directory structure stored inside the archive. If you also work with tarballs, use a different workflow to extract .gz and .tgz files in Linux, because unzip only handles ZIP archives.
Check Whether unzip Is Already Available
Before you install anything, check whether unzip is already on your system:
command -v unzip
A successful result usually looks like this:
/usr/bin/unzip
If the command prints a path, unzip is installed and ready to use. It is a better first check than unzip -v when you only want to confirm the binary exists, because it avoids a long build-information dump. If it prints nothing or your shell reports unzip: command not found, install the package with the commands in the next section.
unzip Command Syntax
The basic syntax is short:
unzip [options] archive.zip [-d destination]
Each part controls a different part of the extraction process:
- unzip runs the extraction command.
- [options] changes how extraction works, for example
-oto overwrite files or-nto keep existing files. - archive.zip is the ZIP file you want to inspect or extract.
- [-d destination] sends the extracted files to another directory instead of the current one.
At its simplest, unzip archive.zip extracts everything into the current directory. To send the same archive somewhere else, append -d /path/to/destination.
Common unzip Options by Task
This quick reference groups the most useful options by what you are trying to do:
| Task | Command or Option | What It Does |
|---|---|---|
| Extract into the current directory | unzip archive.zip | Unpacks the entire archive where you are currently working. |
| Extract to another directory | -d /path/to/destination | Sends the extracted files to a different location and creates the destination directory if needed. |
| List contents without extracting | -l | Shows file names, sizes, and stored paths without changing anything on disk. |
| Show a detailed listing | -v | Displays compression methods, ratios, CRC values, and timestamps. |
| Test archive integrity | -t | Checks the archive for corruption before you extract it. |
| Overwrite existing files | -o | Replaces matching files without asking for confirmation. |
| Keep existing files | -n | Skips files that already exist in the destination. |
| Flatten stored directories | -j | Extracts files without recreating the directory tree stored in the archive. |
| Exclude files or directories | -x pattern | Skips anything that matches the supplied pattern. |
| Restore extra Unix attributes | -X | Restores supported extended attributes when the archive contains them. |
You can combine options when they solve different problems. For example, unzip -q -o archive.zip -d /tmp/extract overwrites files quietly into a different directory.
Install the unzip Command
If command -v unzip returns nothing, install the package from your distribution repositories:
# Ubuntu and Debian
sudo apt install unzip
# Fedora, RHEL, Rocky Linux, and AlmaLinux
sudo dnf install unzip
# Arch Linux and Manjaro
sudo pacman -S unzip
# openSUSE
sudo zypper install unzip
# Alpine Linux
sudo apk add unzip
# Gentoo
sudo emerge app-arch/unzip
After installation, rerun command -v unzip to confirm that the binary is on your PATH.
On Alpine or other BusyBox-heavy environments, install the standalone unzip package when you want the full Info-ZIP option set. Minimal archive utilities do not always match the same flags or output format.
Practical unzip Command Examples
Most unzip work comes down to four things: extracting archives, checking what is inside them, verifying that the ZIP file is intact, and controlling how existing files are handled.
Extract to a Specific Directory
When you want the extracted files to land in a dedicated folder instead of your current working directory, use -d. Here, -d means destination directory. If the folder does not exist yet, you can create directories with mkdir, or let unzip create the destination automatically.
unzip archive.zip -d /path/to/destination
A run like this starts extracting the stored files into the destination directory:
Archive: archive.zip inflating: /path/to/destination/file1.txt inflating: /path/to/destination/notes.txt inflating: /path/to/destination/file2.txt
This is the core pattern behind most unzip to directory searches: keep the archive where it is and send the extracted files to a different location.
Extract in the Current Directory
If you are already standing in the directory where the files should land, run unzip without any extra options:
unzip archive.zip
This extracts the archive contents into the current directory and recreates any folders stored inside the ZIP file.
Extract Multiple Archives at Once
When a directory contains several ZIP files, a short loop can process all of them. Sending each archive into its own directory avoids filename collisions between different extracts.
for archive in *.zip; do
[ -e "$archive" ] || continue
unzip "$archive" -d "${archive%.zip}"
done
This loop skips the body if no ZIP files are present, then extracts each archive into a directory named after the archive file. If those generated folder names need cleanup later, you can rename directories with mv.
Overwrite Existing Files Without Prompting
Automated workflows break when unzip pauses to ask whether a file should be replaced. Use -o when you want the archive copy to win every time.
unzip -o archive.zip
This replaces existing files with matching names without interactive prompts, which makes it suitable for scripts and repeatable deployment steps.
Skip Overwriting Existing Files
Use -n when local files should stay untouched and you only want missing files from the archive:
unzip -n archive.zip
This keeps existing files in place and extracts only the files that are not already present in the destination directory.
List Archive Contents Without Extracting
Before you unpack anything, check the archive contents with -l:
unzip -l archive.zip
A standard listing looks like this:
Archive: archive.zip
Length Date Time Name
--------- ---------- ----- ----
6 2026-03-15 10:16 file1.txt
11 2026-03-15 10:16 notes.txt
5 2026-03-15 10:16 file2.txt
--------- -------
22 3 files
This is the safest way to confirm filenames, sizes, and stored paths before extraction.
Show Detailed Archive Information
When you need more than filenames, use -v for a verbose listing. Compression ratios, timestamps, and CRC values vary by archive, but the output format looks like this:
unzip -v archive.zip
Archive: archive.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
6 Defl:N 8 -33% 03-15-2026 10:16 9f606eec file1.txt
11 Defl:N 13 -18% 03-15-2026 10:16 f7293622 notes.txt
5 Defl:N 7 -40% 03-15-2026 10:16 e6e3a775 file2.txt
-------- ------- --- -------
22 28 -27% 3 files
Use this view when you need CRC data, stored timestamps, or compression ratios before you decide whether to extract the archive. For very small files, negative compression percentages are normal because ZIP metadata can be larger than the original content.
Test Archive Integrity Before Extraction
If the archive came from an unreliable download or a third-party source, run an integrity test before extracting it:
unzip -t archive.zip
A clean archive returns output like this:
Archive: archive.zip testing: file1.txt OK testing: notes.txt OK testing: file2.txt OK No errors detected in compressed data of archive.zip.
If any file fails, stop there and replace the archive before you scatter partial or damaged files across your system.
Restore Extended Attributes and Permissions
Archives created on Unix-like systems can store more than plain file contents. Use -X when you want unzip to restore supported extended attributes in addition to the normal stored file metadata.
unzip -X archive.zip
This is most useful for archives created on Linux or other Unix-like systems. If you need to adjust the results afterward, you can change file permissions with chmod.
Exclude Specific Files or Patterns
Many ZIP files contain logs, temporary files, or platform-specific metadata you do not need. Use -x to skip matching paths during extraction:
unzip archive.zip -x '*.log' '__MACOSX/*'
This extracts everything except files matching *.log and the macOS metadata directory __MACOSX/. Add more patterns as needed, separated by spaces.
Troubleshoot Common unzip Errors
These are the unzip problems readers hit most often when the archive path is wrong, the package is missing, or the file is not a valid ZIP archive.
Fix unzip: command not found
If your shell returns this error:
bash: unzip: command not found
The unzip package is not installed, or the binary is not on your shell PATH. Install the package for your distribution, then verify the command location:
command -v unzip
A working result usually prints a full path like this:
/usr/bin/unzip
Fix End-of-central-directory Signature Errors
If unzip prints an error like this:
End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive.
The file is either damaged, incomplete, or not a real ZIP archive even if it ends in .zip. Test the archive directly before extracting it:
unzip -t archive.zip
A healthy archive ends with output like this:
No errors detected in compressed data of archive.zip.
If the test fails, download the archive again and confirm that the source actually provides a ZIP file rather than another archive format.
Fix cannot find or open archive.zip
If you run unzip from the wrong directory or misspell the archive name, you will see an error like this:
unzip: cannot find or open archive.zip, archive.zip.zip or archive.zip.ZIP.
Use the full archive path and point unzip at a directory you know exists. If needed, create the destination first:
mkdir -p "$HOME/extract"
unzip "$HOME/Downloads/archive.zip" -d "$HOME/extract"
Once the path is correct, extraction begins like this:
Archive: /home/user/Downloads/archive.zip inflating: /home/user/extract/file1.txt
unzip Command FAQ
Yes. When you run unzip archive.zip -d /path/to/destination, unzip creates the destination directory if it does not already exist, then extracts the archive contents there.
unzip -l lists filenames and sizes without extracting anything. unzip -t tests the archive for corruption. unzip -v shows a more detailed listing with compression methods, ratios, CRC values, and timestamps.
Yes. Add the stored path after the archive name, for example unzip archive.zip path/inside/archive.txt. That extracts only the requested file or directory instead of the full archive.
Alpine can install the standalone Info-ZIP package with apk add unzip, and that package uses the same unzip syntax as the standard Info-ZIP tool on other Linux distributions. Very small BusyBox-based environments may rely on different archive utilities with a reduced flag set, so install the standalone unzip package when you want the full Info-ZIP option set.
Conclusion
unzip is ready for the ZIP jobs that come up most often on Linux, whether you need a clean destination directory, a quick contents check, or an integrity test before extraction. When the file is not a ZIP archive at all, switch to the matching archive tool instead of forcing unzip onto the wrong format.
zip is the best format to use for the most compatibility across the operating systems. I’ve been using it since windows 3.11.