Zip Files: zip and unzip

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.zip

In 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.zip

In 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/project

In 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.txt

In 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
Tasktarzip
Createtar -czf x.tar.gz dirzip -r x.zip dir
Listtar -tf x.tar.gzunzip -l x.zip
Extracttar -xzf x.tar.gzunzip x.zip
Compresses?Only with z/j/JAlways

Tip: On Linux and for backups, .tar.gz is usual because it keeps every detail of file ownership and permissions. Reach for .zip when you're sharing with someone on Windows or Mac.

Remember: zip -r out.zip folder makes a zip, unzip out.zip opens it, unzip -l lists it. Zip always compresses and is the format to share with other systems.

HOME LEARN COMMUNITY DASHBOARD
Practice terminal Starting…