$linuxjunkies
>

zip(1)

Create or modify compressed archive files in ZIP format.

UbuntuDebianFedoraArch

Synopsis

zip [OPTION]... [-b path] [-t mmddyyyy] [-n suffixes] [zipfile [file]...]

Description

The zip command compresses files into a single archive in ZIP format, compatible with Windows and most other systems. It preserves file permissions and directory structure by default, and can update existing archives incrementally.

When no files are specified, zip reads a list from standard input. Directories are recursively archived unless -r is omitted. Original files remain unchanged unless -m is used to move them into the archive.

Common options

FlagWhat it does
-rRecursively include all files and subdirectories
-eEncrypt archive with a password (prompts for input)
-mMove files into archive (delete originals after zipping)
-qQuiet mode; suppress informational messages
-uUpdate archive; only add or replace newer files
-dDelete entries from existing archive
-lStore files with Unix line endings (LF) instead of CRLF
-0Store files without compression (store only)
-9Maximum compression (slowest; default is -6)
-jJunk paths; store only file names, not directory structure
-xExclude files matching pattern (e.g., -x '*.log')
-vVerbose; print filenames and compression ratios

Examples

Create a new ZIP archive with two files

zip archive.zip file1.txt file2.txt

Recursively archive an entire directory and its contents

zip -r project.zip myproject/

Create a password-protected archive (prompts for password)

zip -e secure.zip important.doc

Update existing archive, adding or replacing only newer .txt files

zip -u backup.zip *.txt

Move all .log files into archive and delete the originals

zip -m archive.zip logs/*.log

Archive a directory while excluding .tmp and .cache files

zip -r -x '*.tmp' '*.cache' archive.zip project/

Archive without compression (faster for already-compressed files)

zip -0 -r nocompress.zip media/

Remove a file from an existing ZIP archive

zip -d archive.zip oldfile.txt

Related commands