Cheatsheet: Zip

Last updated 2026-09-25

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

Compression, Exclude Patterns & Splitting

Exclude multiple patterns or a whole directory

zip -r archive_name.zip /path/to/directory -x '*.log' '*.tmp' 'node_modules/*'

Store files with no compression (fastest, for already-compressed data)

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

Store only file names, discarding directory paths

zip -j archive_name.zip /path/to/directory/*

Split an archive into fixed-size volumes

zip -s 100m -r archive_name.zip /path/to/directory

Recombine split volumes back into one archive

zip -s 0 archive_name.zip --out combined.zip

List the files stored in an archive without extracting

zip -sf archive_name.zip

Show detailed per-entry info (size, ratio, date)

zipinfo archive_name.zip

FAQ