Create zip archives with the zip command

Pack files or a folder into a .zip that opens anywhere — Windows, macOS, phones.

LinuxZip & ArchivesarchiveLow risk
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 *.pdf

02What 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

RiskLow risk
!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

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions