LinuxCommandLibrary

zip

TLDR

Create a ZIP archive

$ zip [archive.zip] [file1] [file2]
copy
Create archive from directory
$ zip -r [archive.zip] [directory/]
copy
Add files to existing archive
$ zip [archive.zip] [newfile.txt]
copy
Create archive with compression level
$ zip -9 [archive.zip] [files]
copy
Create encrypted archive
$ zip -e [archive.zip] [files]
copy
Exclude files from archive
$ zip -r [archive.zip] [directory/] -x "*.log"
copy
Update only changed files
$ zip -u [archive.zip] [files]
copy
Create archive excluding directory
$ zip -r [archive.zip] [dir/] -x [dir/subdir/*]
copy
Delete file from archive
$ zip -d [archive.zip] [file_to_remove]
copy

SYNOPSIS

zip [options] archive files...

DESCRIPTION

zip creates and modifies ZIP archives, a widely supported compressed archive format. It compresses files using the DEFLATE algorithm (or store without compression) and packages them with metadata including names, timestamps, and permissions.
ZIP archives are cross-platform compatible and supported natively on Windows, macOS, and most Unix systems. The format supports directory structures, encryption, and archives spanning multiple files.
zip can create new archives, add files to existing ones, update changed files, or delete entries. It's commonly used for file distribution, backups, and data exchange.

PARAMETERS

-r

Recurse into directories.
-9
Maximum compression.
-0
Store only (no compression).
-e
Encrypt archive (prompts for password).
-P password
Use specified password.
-u
Update only changed files.
-f
Freshen (update existing entries only).
-d
Delete entries from archive.
-x pattern
Exclude files matching pattern.
-i pattern
Include only matching files.
-j
Junk directory paths.
-q
Quiet mode.
-v
Verbose output.
-@
Read file list from stdin.
-s size
Split archive at size.
-y
Store symbolic links.

CAVEATS

Default encryption is weak (ZipCrypto); use 7z for strong encryption. Maximum file size is 4GB without ZIP64. Password on command line is insecure. Timestamps may lose precision.

HISTORY

The ZIP format was created by Phil Katz for PKZIP in 1989. The Info-ZIP project was started the same year to provide free implementations. Info-ZIP's zip became the standard Unix ZIP utility and is included in virtually all Unix-like systems. The format has evolved to support larger files (ZIP64) and better compression.

SEE ALSO

unzip(1), tar(1), gzip(1), 7z(1)

> TERMINAL_GEAR

Curated for the Linux community

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99