Session and utilities
The unzip command
Extracts .zip archives, and can list their contents without extracting them.
Most useful options
-lLists the contents in short format, without extracting-d carpetaExtracts into the given folder, instead of the current one-oOverwrites existing files without asking-nNever overwrites: skips files that already exist-jIgnores the folders in the zip and puts all files flat in the destination-tChecks the integrity of the archive without extracting it-qQuiet mode, without a message for each fileCopy-ready examples
$ printf 'hola\n' > f.txt && zip p.zip f.txt && unzip -l p.zipcreates a test zip and lists its contents without extracting them.$ unzip archivo.zip -d destinoextracts the zip into the destino folder.$ unzip -t copia.zipchecks that the zip is not damaged, without extracting anything.$ unzip -n datos.zip -d datosextracts without touching what you already have in the datos folder.$ unzip -o copia.zip -d proyectooverwrites without asking the files that already exist in proyecto. List first with -l.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| unzip: cannot find or open noexiste.zip, noexiste.zip.zip or noexiste.zip.ZIP. | The file does not exist at that path or the name is misspelled. | List the folder with ls and copy the exact name. |
| End-of-central-directory signature not found. Either this file is not | The file is not a valid zip: it may be incomplete or of another type, even if it ends in .zip. | Download it again or check its type with file archivo. |
Typical mistakes
- If a file already exists, unzip asks what to do, and a script is left waiting: use -n or -o to decide in advance.
- With -o it overwrites without asking; with -n it skips what already exists.
- If the file ends in .zip but is not a real zip, unzip will not open it: check its type with file.
Differences from similar commands
Security
Before extracting a zip from an untrusted source, list its contents with -l to see the path names.
FAQ
How do I extract to another folder?
With unzip archive.zip -d folder.
How do I check that the zip is not damaged?
With unzip -t archive.zip, which reads all the contents without extracting them.
How do I extract only one file?
Give its name after the zip: unzip archive.zip report.txt.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course