Compression

zip

Package and compress files into a ZIP archive compatible with all operating systems.

Synopsis

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

Examples

Create ZIP of specific files
zip archive.zip file1.txt file2.txt
Zip directory excluding git files
zip -r project.zip src/ -x '*.git*'
Create password-protected ZIP
zip -e secure.zip secrets.txt
Best compression for directory
zip -r -9 deploy.zip dist/

Common options

FlagDescription
-rRecurse into directories
-eEncrypt with password
-xExclude files matching pattern
-9Best compression
-jJunk (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

Related tools