Cheatsheet: Zip

Basic Archiving Commands

Create a zip archive from a directory

zip -r archive_name.zip /path/to/directory

Create a zip archive from multiple files

zip archive_name.zip file1 file2 file3

Create a zip archive with maximum compression

zip -9 archive_name.zip /path/to/directory

Exclude specific files or directories

zip -r archive_name.zip /path/to/directory -x excluded_file_or_dir

Advanced Options

Add files to an existing zip archive

zip archive_name.zip new_file

Update specific files in an archive

zip -u archive_name.zip updated_file

Delete a file from a zip archive

zip -d archive_name.zip file_to_remove

Create a password-protected zip archive

zip -e archive_name.zip /path/to/directory

Fix a corrupt zip archive (minor issues)

zip -F corrupted_archive.zip --out fixed_archive.zip

Fix a corrupt zip archive (more intensive)

zip -FF corrupted_archive.zip --out fixed_archive.zip

See also: