ubuntutorials
Ubuntu 26.04 · 24.04 · 22.04

How to Unzip a File on Ubuntu

Install unzip, extract an archive where you actually want it, look inside before you commit, and handle the overwrite prompt. Tested on 26.04, 24.04 and 22.04.

Verified
Tested end to end on real servers running Ubuntu 26.04 LTS (kernel 7.0.0-27), 24.04.4 LTS (6.8.0-134) and 22.04.5 LTS (5.15.0-185), today.

Type your own and every command below updates. Nothing leaves your browser.

Ubuntu doesn’t come with unzip. Not on the desktop, not on the server, not on any of the cloud images I’ve tested this on, which is why the first thing most people meet is unzip: command not found.

It’s one package away, and then it’s three flags worth knowing.

Before You Start

  • A machine running Ubuntu 26.04, 24.04 or 22.04, whether you’re sat in front of it or logged in over SSH
  • A .zip file to extract
  • sudo access, for the install in step 1 and nothing after it. Adding a user and giving them sudo covers it if the account you’re on hasn’t got it

Step 1: Install unzip

sudo apt update
sudo apt install -y unzip

It’s a small package from Ubuntu’s own archive, so this takes a couple of seconds and pulls in nothing surprising.

Step 2: Extract It

unzip yourfile.zip
Archive:  yourfile.zip
  inflating: report.txt
   creating: notes/
  inflating: notes/todo.md

Everything lands in the directory you’re standing in. Folders inside the archive stay folders, which is the behaviour you want and also the reason the next step exists.

Step 3: Look Inside First

unzip -l yourfile.zip
Archive:  yourfile.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       18  2026-08-08 14:20   report.txt
        0  2026-08-08 14:20   notes/
       10  2026-08-08 14:20   notes/todo.md
---------                     -------
       28                     3 files

Some archives hold a single tidy folder. Others hold forty loose files that will scatter across whatever directory you were in, and you only find out afterwards. -l is five seconds well spent, and it’s the habit worth forming.

Step 4: Extract Somewhere Specific

unzip yourfile.zip -d ~/extracted

-d says where to put it, and creates the directory if it isn’t there yet. Between this and step 3 you can stop worrying about what a strange archive is going to do to your home directory.

Step 5: Extract It Again Without the Questions

unzip -o yourfile.zip -d ~/extracted

Extract into a directory that already holds those files and unzip stops at each one to ask whether to replace it, which is fine for two files and tedious for two hundred. -o overwrites the lot without asking. -n is the opposite and skips anything already there.

Verify It Worked

The commands above all report success on their way past, so the check worth making is whether the archive’s contents and the disk actually agree:

count=$(unzip -Z1 yourfile.zip | grep -vc '/$'); found=$(find ~/extracted -type f | wc -l); [ "$count" = "$found" ] && echo "every file in the archive is on disk"
every file in the archive is on disk

unzip -Z1 lists what the archive says it holds, the find counts what came out, and the two should match. Folders are dropped from the count on purpose: an archive listing counts its directories as entries, which is why -l above reports three files when only two of them are files.

If the numbers disagree, unzip will have said why further up, and a truncated download is the usual answer.

Conclusion

You’ve got unzip installed and the three flags that cover almost every use of it: -l to look, -d to aim, -o to stop it asking. Ubuntu handles .tar.gz out of the box, so it’s only zip files that need this one-off install.

If you hit an archive that behaves differently, do drop me a line at [email protected] with the Ubuntu version you’re on and I’ll take a look.