Create zip archives with the zip command
Pack files or a folder into a .zip that opens anywhere — Windows, macOS, phones.
Run zip -r archive.zip folder/ to zip a whole directory, or zip archive.zip file1 file2 for loose files.
01Command
Command
$ zip -r project.zip project/ && zip -9 report.zip *.pdf02What it does
zip is the reciprocal of unzip: -r is required to include directory contents, otherwise only the empty folder is stored. -9 applies maximum compression (slowest, smallest), and -e adds a password. The archive keeps relative paths, so run it from the parent of the folder you're packing for a tidy structure.
03Risk
!Warning: If the .zip already exists, zip updates/adds matching files into it instead of creating a fresh archive — delete the old .zip first if you want a clean rebuild. zip's default encryption (-e) is weak; use 7z for sensitive data.
04Undo
Undo
$ unzip project.zip (restores contents; delete the archive to undo)05Sources
- zip(1) — package and compress (archive) filesEvidence: zip -r recurses into directories to archive whole folder trees; -9 uses maximum compression.
Last verified: 2026-09-18 · Category: Files & Folders