Archives

Linux zip command

Create a ZIP archive. Add -r when including a directory tree.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

zip [OPTION]... ARCHIVE.zip FILE...

Examples

Add a directory tree to a ZIP archive.

zip -r site-backup.zip ./site

Update the archive with a changed file.

zip -u site-backup.zip ./site/index.html

Parameters, options and clauses

Option / clauseDescription
-rRecurse into directories.
-uUpdate entries only when source files are newer or missing.
-d ARCHIVE FILE...Delete entries from an existing archive.
-eEncrypt archive entries with a password prompt.
-qQuiet operation.
-x PATTERNExclude matching paths.
-9Request the slowest, highest compression level.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory