Skip to main content

ZIP/UNZIP Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for creating, listing, testing, and extracting ZIP archives in Linux

ZIP archives are widely used for sharing files across Linux, macOS, and Windows. This cheatsheet covers the most common `zip` and `unzip` command patterns for creating archives, updating them, and extracting files safely.

Basic Syntax

Common command forms for ZIP operations.

CommandDescription
zip [OPTIONS] archive.zip filesCreate or update ZIP archive
unzip [OPTIONS] archive.zipExtract ZIP archive
zip -r archive.zip directory/Recursively archive a directory
unzip archive.zip -d /path/Extract to a specific directory
unzip -t archive.zipTest archive integrity

Create ZIP Archives

Create archives from files and directories.

CommandDescription
zip archive.zip file1 file2Archive multiple files
zip -r project.zip project/Archive directory recursively
zip -j archive.zip path/to/fileArchive files without directory paths (flat)
zip -9 -r backup.zip /etc/Maximum compression
zip -0 -r store.zip media/No compression (faster)
zip -r logs.zip /var/log -x "*.gz"Exclude matching files
zip -q -r archive.zip dir/Create archive silently (no output)

Update Existing Archives

Add, refresh, or remove archive entries.

CommandDescription
zip archive.zip newfile.txtAdd file to existing archive
zip -r archive.zip newdir/Add directory to existing archive
zip -u archive.zip file.txtUpdate only changed files
zip -d archive.zip "*.tmp"Delete matching entries
zip -FS archive.zipSync archive with filesystem state

List and Inspect

Check archive contents before extraction.

CommandDescription
unzip -l archive.zipList archived files
unzip -Z -v archive.zipDetailed listing (sizes, ratio, methods)
zipinfo archive.zipDisplay archive metadata
zipinfo -1 archive.zipList filenames only
unzip -t archive.zipTest archive integrity

Extract Archives

Extract all files or selected paths.

CommandDescription
unzip archive.zipExtract into current directory
unzip archive.zip -d /tmp/extractExtract to target directory
unzip archive.zip file.txtExtract one file
unzip archive.zip "dir/*"Extract matching path pattern
unzip -n archive.zipNever overwrite existing files
unzip -o archive.zipOverwrite existing files without prompt
unzip -q archive.zipExtract silently (no output)

Password-Protected Archives

Create and extract encrypted ZIP files.

CommandDescription
zip -e secure.zip file.txtCreate encrypted archive (interactive password)
zip -er secure-dir.zip secrets/Encrypt directory archive
unzip secure.zipExtract encrypted ZIP (prompts for password)
zipcloak archive.zipAdd encryption to an existing archive
zipcloak -d archive.zipRemove encryption from archive

Split Archives

Split large ZIP files into smaller chunks.

CommandDescription
zip -r -s 100m backup.zip bigdir/Create split archive with 100 MB parts
zip -s 0 split.zip --out merged.zipRecombine split ZIP into one file
unzip split.zipExtract split archive (all parts required)
zip -s 2g -r media.zip media/Create split archive with 2 GB parts

Troubleshooting

Common ZIP/UNZIP problems and checks.

IssueCheck
unzip: cannot find or openVerify path and filename, then run ls -lh archive.zip
CRC error during extractionRun unzip -t archive.zip to test integrity
Files overwritten without warningUse unzip -n archive.zip to skip existing files
Wrong file permissions after extractCheck with ls -l, then adjust using chmod/chown
Password prompt failsRe-enter password carefully; verify archive is encrypted with zipinfo

Use these guides for full walkthroughs.

GuideDescription
How to Zip Files and Directories in LinuxDetailed ZIP creation examples
How to Unzip Files in LinuxDetailed extraction methods
Tar CheatsheetTar and compressed archive reference