zip

zip creates and extracts ZIP archives, compresses or expands single-file GZIP streams, lists contents, tests integrity and controls compression level.

ArchivesVersion 1.2.5Stable
lil-terminal

Overview

Use ZIP for compressed directory trees and GZIP when only one file needs compression. Inspect or test before extraction, keep overwrite explicit with -f, and use -d only when the source should be removed after successful creation.

ZIP packs trees; GZIP compresses one file

ZIP can contain many files and directories. GZIP contains one compressed data stream, so zip <file> -gz is not a second archive tree. Both formats use the same safe path and conflict rules where those rules apply.

Syntax

lil-terminal
zip <src|arc.zip|file.gz|file.bz2> [dst] [options]

Reference

zip <src> [dst]

create a ZIP archive

zip <arc.zip> [dst]

extract a ZIP archive into the current directory or <dst>

zip <file.gz|file.bz2> [dst]

decompress a GZIP or BZIP2 file

ZIP archives and single-file streams

For a directory use zip data tmp/data.zip: ZIP stores a file tree with compression. -gz and -bz2 work differently — they compress one regular file, not a directory. GZIP needs zlib; BZIP2 needs the PHP bz2 extension.

Choose compression with care

ZIP uses DEFLATE by default. -0 stores files without compression; -1 through -9 control the level when supported. -m store|deflate|bzip2|lzma|zstd selects the method inside a .zip, not a different archive extension. Some methods require newer libzip builds and may not be readable everywhere.

Check, extract, replace

-l lists entries without extraction; -t reads them to test integrity. Extract by passing an existing .zip, .gz or .bz2 as source. Conflicting destination files are preserved unless -f is specified. -d deletes the source only after successful creation (requires del).

Safe extraction and predictable output

Unsafe paths, duplicate entries and symbolic-link entries are rejected. After creating or extracting a ZIP, the command shows one flat directory listing instead of printing the entire tree.

Interactive sandbox preview

Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.

Create a ZIP archive

Install and manage

Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.

Base and Minimum are two packages of the same current module release, not separate command versions.

Base package

Install the complete package with local command reference and every published mode.

install zip
Minimum package

Install the reduced package. Local reference is omitted; help <cmd> -i opens the current server reference.

install zip -m
Exact public version

Install exactly this published version.

install zip -v 1.2.5
Check or update

Ask upgrade to check compatibility and replace the installed block only when needed.

upgrade zip
Remove module

Remove the extension block while leaving the core and unrelated modules intact.

install zip -u

Examples

Examples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.

Create a ZIP archive
cd \sandbox | zip data tmp/data.zip
sandbox

README.txt
current.txt
data.tar
data.zip
draft.txt
new.txt
Zip · list
zip tmp/data.zip -l
data/             directory
data/sample.csv   file · 59 B
data/sample.txt  file · 100 B
data/users.json  file · 102 B
Zip · test
zip tmp/data.zip -t
Status   Archive OK
Entries  4
Files    3
Size     261 B
Extract a ZIP archive into the current directory or <dst>
zip tmp/data.zip tmp/restored
data/
Create a ZIP archive
zip data tmp/data.zip
Archive already exists
Zip · data
zip data tmp/data.zip -f
README.txt
current.txt
data.tar
data.zip
draft.txt
new.txt
Zip · data
zip data tmp/data-0.zip -0
README.txt
current.txt
data-0.zip
data.tar
data.zip
draft.txt
new.txt
Zip · data
zip data tmp/data-9.zip -9
README.txt
current.txt
data-9.zip
data.tar
data.zip
draft.txt
new.txt
Zip · data
zip data tmp/data-store.zip -m store
data-store.zip
data.tar
data.zip
Zip · data
zip data tmp/data-deflate.zip -m deflate
data-deflate.zip
data.tar
data.zip
Zip · data
zip data tmp/data-zstd.zip -m zstd
ZIP compression method is not supported on this host
Zip · log
zip logs/app.log tmp/app.log.gz -gz
app.log.gz
app.log
Zip · gz
zip tmp/app.log.gz -l
File        app.log
Compressed  92 B
Original    96 B
Zip · gz
zip tmp/app.log.gz -t
Status  Archive OK
Size    96 B
Decompress a GZIP or BZIP2 file
zip tmp/app.log.gz tmp/restored.log
restored.log
Zip · log
zip logs/app.log tmp/app.log.bz2 -bz2
bz2 extension required
Decompress a GZIP or BZIP2 file
zip tmp/app.log.bz2 tmp/restored.log
restored.log
Zip · txt
zip tmp/draft.txt tmp/draft.zip -d
draft.zip
data.zip
(source draft.txt removed only after successful creation)
Extract a ZIP archive into the current directory or <dst>
zip missing.zip
Source not found

File used in this example: sandbox/data/sample.txt

The example uses a file or directory from the protected /sandbox/ documentation workspace.

lil-terminal sandbox text file

This file is safe to read, copy, rename, replace, hash and archive.

Related documentation

Current public release

v1.2.52026-11-01

Production refinement

Current stable release of zip. zip creates and extracts ZIP archives, compresses or expands single-file GZIP streams, lists contents, tests integrity and controls compression level.