zip: one step, and cross-platform
.zip is the archive format everyone shares with Windows and Mac. Unlike tar, a .zip both bundles and compresses in one go. Use -r (recursive) to include a whole folder:
zip -r project.zip project
ls -l project.zipIn the terminal
student@vulntech:~$ zip -r project.zip project adding: project/ (stored 0%) adding: project/src/ (stored 0%) adding: project/src/main.py (stored 0%) adding: project/src/util.py (stored 0%) adding: project/docs/ (stored 0%) adding: project/docs/readme.txt (stored 0%) adding: project/VERSION (stored 0%) student@vulntech:~$ ls -l project.zip -rw-r--r-- 1 student student 1171 Oct 17 15:07 project.zip
Listing and extracting
unzip -l lists the contents; plain unzip extracts them:
unzip -l project.zipIn the terminal
student@vulntech:~$ unzip -l project.zip Archive: project.zip Length Date Time Name --------- ---------- ----- ---- 0 2026-10-17 15:10 project/ 0 2026-10-17 15:10 project/src/ 12 2026-10-17 15:10 project/src/main.py 7 2026-10-17 15:10 project/src/util.py 0 2026-10-17 15:10 project/docs/ 11 2026-10-17 15:10 project/docs/readme.txt 5 2026-10-17 15:10 project/VERSION --------- ------- 35 7 files
mkdir out; unzip project.zip -d out
ls out/projectIn the terminal
student@vulntech:~$ mkdir out; unzip project.zip -d out Archive: project.zip creating: out/project/ creating: out/project/src/ extracting: out/project/src/main.py extracting: out/project/src/util.py creating: out/project/docs/ extracting: out/project/docs/readme.txt extracting: out/project/VERSION student@vulntech:~$ ls out/project VERSION docs src
-d here means the directory to extract into (not delete as with gzip); unzip makes the folder if it's missing.
Adding to and reading a zip
Add more files to an existing archive just by zipping into it again, and read one file without unpacking with unzip -p (it prints to standard output):
echo 'release notes' > NOTES.txt
zip project.zip NOTES.txt
unzip -p project.zip NOTES.txtIn the terminal
student@vulntech:~$ echo 'release notes' > NOTES.txt student@vulntech:~$ zip project.zip NOTES.txt adding: NOTES.txt (stored 0%) student@vulntech:~$ unzip -p project.zip NOTES.txt release notes
| Task | tar | zip |
|---|---|---|
| Create | tar -czf x.tar.gz dir | zip -r x.zip dir |
| List | tar -tf x.tar.gz | unzip -l x.zip |
| Extract | tar -xzf x.tar.gz | unzip x.zip |
| Compresses? | Only with z/j/J | Always |
Tip: On Linux and for backups,
.tar.gzis usual because it keeps every detail of file ownership and permissions. Reach for.zipwhen you're sharing with someone on Windows or Mac.
Remember:
zip -r out.zip foldermakes a zip,unzip out.zipopens it,unzip -llists it. Zip always compresses and is the format to share with other systems.