zip
Package and compress files into a ZIP archive compatible with all operating systems.
Synopsis
zip [OPTION]... ARCHIVE FILE...
Examples
zip archive.zip file1.txt file2.txt
zip -r project.zip src/ -x '*.git*'
zip -e secure.zip secrets.txt
zip -r -9 deploy.zip dist/
Common options
| Flag | Description |
|---|---|
| -r | Recurse into directories |
| -e | Encrypt with password |
| -x | Exclude files matching pattern |
| -9 | Best compression |
| -j | Junk (don't record) directory names |
About zip
The `zip` command package and compress files into a ZIP archive compatible with all operating systems. Compression commands reduce file sizes for storage and transfer.
Linux supports multiple compression formats, each with different speed and ratio trade-offs. Understanding these tools is essential for working with archives, backups, log rotation, and software distribution packages.
The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man zip`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Compression Commands
Other commands in the Compression category