unzip Command
Beginner Compression & Archives man(1)Extract files from ZIP archives
👁 11 views
📅 Updated: Mar 15, 2026
SYNTAX
unzip [OPTION]... ARCHIVE [FILE]...
What Does unzip Do?
unzip extracts files from ZIP archives. It supports listing contents, extracting specific files, testing archive integrity, and handling password-protected archives.
unzip is the complement to zip — it extracts what zip creates. It handles ZIP files from any platform (Windows, macOS, Linux) and preserves file permissions where possible.
unzip is the tool to use when you receive a .zip file. For .tar.gz, .tar.bz2, or .tar.xz files, use tar instead.
unzip is the complement to zip — it extracts what zip creates. It handles ZIP files from any platform (Windows, macOS, Linux) and preserves file permissions where possible.
unzip is the tool to use when you receive a .zip file. For .tar.gz, .tar.bz2, or .tar.xz files, use tar instead.
Options & Flags
| Option | Description | Example |
|---|---|---|
| -l | List archive contents | unzip -l archive.zip |
| -d | Extract to specific directory | unzip archive.zip -d /opt/ |
| -o | Overwrite without prompting | unzip -o update.zip |
| -n | Never overwrite existing files | unzip -n archive.zip |
| -t | Test archive integrity | unzip -t archive.zip |
| -j | Ignore directory structure (extract flat) | unzip -j archive.zip |
| -P | Provide password on command line | unzip -P secret archive.zip |
Practical Examples
#1 Extract archive
Extracts all files from the archive.
$ unzip archive.zip#2 Extract to directory
Extracts to a specific directory.
$ unzip release.zip -d /opt/app/#3 List contents
Lists all files without extracting.
$ unzip -l archive.zip
Output:
Length Date Time Name\n 12345 01-15-24 14:30 file.txt
#4 Test integrity
Verifies archive is not corrupted.
$ unzip -t archive.zip
Output:
No errors detected in compressed data of archive.zip.
#5 Extract specific file
Extracts only the specified file from the archive.
$ unzip archive.zip path/to/file.txt#6 Overwrite all
Extracts and overwrites existing files without asking.
$ unzip -o update.zip -d /var/www/Tips & Best Practices
Always list first: Use unzip -l first to check contents. Some archives extract directly into the current directory without a subdirectory.
Wildcard extraction: Extract specific types: unzip archive.zip '*.txt' extracts only .txt files.
Password on command line: Using -P password is insecure (visible in process list). Let unzip prompt for the password instead.
Frequently Asked Questions
How do I extract a zip file?
unzip file.zip. To extract to a specific directory: unzip file.zip -d /target/directory/
How do I list zip contents without extracting?
unzip -l file.zip shows all files, sizes, and dates without extracting.
How do I extract a password-protected zip?
unzip file.zip — it will prompt for the password. Avoid using -P on the command line for security.
Related Commands
More Compression & Archives Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →