Linux zip Command: Create ZIP Archives
zip bundles and compresses files and directories into a single ZIP archive. It is a format often used when exchanging files with other operating systems.
What is the zip command?
The first argument is the ZIP file to create or update, and the following arguments are the files to include. To include files inside directories, specify -r. When running on an existing ZIP file, it does not necessarily create a new archive from scratch, but can update or add existing entries, so confirm your intended action first.
Basic syntax
zip [options] archive.zip file or directory...
Installed implementations and options may vary depending on the distribution. Check your current system's description with man zip.
Examples
Bundling two files
Choose a new ZIP name that does not already exist.
zip documents.zip report.txt notes.txt
Compressing an entire directory
Include subdirectories and files with -r.
zip -r project.zip project/
Check the created archive
After compression, review the file list with unzip -l.
unzip -l project.zip
Checking what is in a ZIP file
zip can put multiple files into a single ZIP archive. -q performs the addition quietly, and listing is done with a separate command.
printf 'hello\n' > note.txt zip -q bundle.zip note.txt unzip -Z -1 bundle.zip
Example output:
note.txt
Just because a name appears in the list doesn't mean the integrity of the archive is verified. You can check the structure with unzip -t bundle.zip. The default encryption of a password-protected ZIP may not be sufficient to protect sensitive information, so if security is the goal, choose an appropriate encryption method separately.
Main Options and Format
| Options/Format | Description |
|---|---|
-r |
Include the subitems of directories recursively. |
-0 |
Store files without compression. |
-1 ... -9 |
Select the compression level. |
-u |
Update changed files in an existing archive. |
-x pattern |
Exclude matching paths. |
Precautions when using
When reusing an existing ZIP file, the configuration content may be updated differently than expected, so either create it with a new name or make a backup first. Do not assume common ZIP password options provide strong security; choose appropriate encryption tools for sensitive data. The ZIP format may not preserve metadata such as permissions and ownership consistently across platforms.
Frequently Asked Questions
Does using `zip project.zip project/` include all the files in the folder?
No. To include the contents of the directory recursively, you usually use `zip -r project.zip project/`.
Official Documentation
You can check the exact behavior of the options and implementation-specific differences in the official documentation for zip.









