unzip Command Cheat Sheet
unzip lists, tests, or extracts compressed files in a ZIP archive.
Synopsis
unzip [options] filename.zip
Basic Usage
Extract to Current Directory
unzip archive.zip
Extract to Specific Directory (-d)
unzip archive.zip -d /var/www/html/
Listing and Testing
List Contents (-l)
See what's inside without extracting.
unzip -l archive.zip
Test Integrity (-t)
Check if the archive is corrupted.
unzip -t archive.zip
# Output: No errors detected in compressed data of archive.zip.
Handling Overwrites
Overwrite All (-o)
Dangerous but useful for scripts.
unzip -o archive.zip
Never Overwrite (-n)
Skip files that already exist.
unzip -n archive.zip
Advanced Filtering
Exclude Files (-x)
Extract everything except matching patterns.
unzip archive.zip -x "*.git/*"
unzip source.zip -x "tests/"
Extract Specific Files
unzip archive.zip "images/*"
Password Protected Zips (-P)
unzip -P "mypassword" secret.zip
Notes
- zipinfo: Detailed technical info about the zip (compression method, version).
zipinfo archive.zip