Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · file management

unzip

open a zip archive

unzip extracts a zip archive into the current directory, recreating the directories stored inside it. It can also list or test an archive without extracting anything, which is the sensible first step.

List first with -l, then extract with -d into a directory of your choosing.

Extracts to
Current directory
unless -d names another
List only
-l
nothing is written
If a file exists
It asks
-o overwrites, -n never does
Test
-t
checks the archive is intact

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

user@netflow — bashunzip
$ unzip -l site.zip
Archive: site.zip
1 Length Date Time Name
--------- ---------- ----- ----
0 2026-09-30 11:40 site/
4210 2026-09-30 11:38 site/index.html
1822 2026-09-29 17:03 site/css/style.css
--------- -------
2 6032 3 files
3$ unzip site.zip -d /tmp/restore
Archive: site.zip
creating: /tmp/restore/site/
4 inflating: /tmp/restore/site/index.html
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
A listing, nothing extracted

Each entry’s original size, date and stored path. Every path begins with site/, so extraction will create one tidy directory.

2
The total when unpacked

6032 bytes across three entries. Worth a glance on a large download, to know the space it needs.

3
-d chooses the destination

The directory is created if it does not exist. Without -d, files land wherever you are standing.

4
creating and inflating

Directories are created, compressed files are inflated back to full size.

Switches

A switch changes how the command behaves. These are the ones used day to day; man unzip lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

-l
List the contents without extracting.
-d DIR
Extract into this directory.
-o
Overwrite existing files without asking.
-n
Never overwrite an existing file.
-t
Test the archive for errors.
-q
Quiet: do not list each file.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

unzip -t backup.zip

Tests every file in the archive for corruption.

unzip site.zip "site/css/*"

Extracts only the entries matching a pattern.

unzip -o update.zip

Overwrites existing files without asking.

unzip -q big.zip -d out

Extracts quietly, without listing every file.

In cybersecurity

An archive from elsewhere is a set of instructions to write files on your machine.

Always list first

An archive with no top directory scatters its files among yours. -l shows this before it happens; -d into an empty directory contains it.

Zip bombs

A few kilobytes can expand into terabytes. The listing shows the unpacked size; be wary of any archive whose total is absurd for its file size.

Paths that climb out

Entries named with ../ try to write outside the destination. Current unzip refuses them, but tools built on other libraries may not.

Filed under

File management

Read alongside