zip
Create compressed archive files
TLDR
Add files/directories to a specific archive
Remove files/directories from a specific archive
Archive files/directories excluding specified ones
Archive files/directories with a specific compression level (0 - the lowest, 9 - the highest)
Create an encrypted archive with a specific password
Archive files/directories to a multi-part split Zip archive (e.g. 3 GB parts)
Print a specific archive contents
SYNOPSIS
zip [options] [zipfile.zip] [file ... | directory/]
PARAMETERS
-r
Recursively archive directory contents.
-q
Quiet mode: suppress output messages.
-v
Verbose mode: show detailed progress.
-e
Encrypt archive with password (prompts interactively).
-d
Delete specified files from existing zipfile.
-u
Update: add newer files to existing archive.
-f
Freshen: update only existing files if newer.
-m
Move files into archive (delete originals after).
-j
Junk paths: store files without directory structure.
-0 to -9
Compression level: -0 (none) to -9 (maximum).
-T
Test archive integrity after creation.
-x pattern
Exclude files matching shell glob patterns.
-i pattern
Include only files matching patterns.
-s size
Split into multi-part archives of given size (e.g., 1g).
-o
Set archive timestamp to latest file's time.
-D
Do not include directory entries.
-g
Grow: append to existing archive.
-h
Display help summary.
DESCRIPTION
The zip command-line utility creates ZIP archives, compressing one or more files or directories into a single portable file for backup, distribution, or storage. Developed by the Info-ZIP project, it implements the ubiquitous ZIP format using the DEFLATE compression algorithm by default, balancing speed and compression ratio effectively.
Key capabilities include recursive directory traversal (-r), password encryption (-e), splitting large archives into volumes (-s), and fine-grained control over what to include or exclude via patterns (-i, -x). It supports updating (-u), freshening (-f), or appending (-g) to existing archives without recreating them entirely. Compression levels range from -0 (store only) to -9 (maximum).
Zip is cross-platform, lightweight, and widely available on Linux, Unix, Windows, and macOS. It handles symbolic links, permissions, and timestamps, though Unicode filenames require explicit handling (-O utf8). Ideal for scripts and automation, it's often paired with unzip for extraction. Limitations include weak legacy encryption and potential issues with very long paths on FAT filesystems.
CAVEATS
Traditional encryption (-e) uses weak ZipCrypto; prefer AES via zip -X or modern tools like 7z. Filenames >255 chars or with colons may fail. Unicode requires -O utf8. Not suitable for streaming large data.
BASIC USAGE EXAMPLE
zip -r backup.zip /home/user/docs/
Recursively zips entire directory.
TEST ARCHIVE
zip -T archive.zip
Verifies zipfile without extracting.
EXCLUDE PATTERNS
zip -r data.zip . -x "*.tmp" "*.bak"
Archives current dir, skipping temp files.
HISTORY
Originating from the Info-ZIP open-source project in 1989, zip 1.0 emulated PKZIP for Unix. Maintained actively, version 3.0 (2008) added AES encryption and Unicode. Now at 3.0+, it's standard in most distros since the 1990s.


