Just downloaded a .zip file from the internet. I want to use the terminal to unzip the file. What is the correct way to do this?

  • 3
    Extract all files from current folder, you can use: unzip \*.zip – burtsevyg Feb 18 '16 at 11:23
  • 2
    @burtsevyg the backslash is not necessary there. It will make shell treat \* as literal star symbol. Just use unzip *.zip to make shell expand * to all files ending in .zip – Sergiy Kolodyazhnyy Jun 2 '17 at 21:55

10 Answers 10

up vote 1577 down vote accepted

If the unzip command isn't already installed on your system, then run:

sudo apt-get install unzip

After installing the unzip utility, if you want to extract to a particular destination folder, you can use:

unzip file.zip -d destination_folder
  • 63
    If you are already in the directory you want the file unzipped, omit the 2nd and 3rd arguments, i.e. unzip /path/to/file.zip – Severo Raz May 26 '13 at 19:13
  • 2
    I have just used this command. This is an example. Step 1 (I changed to the directory where the zip file is stored): cd /home/paf/Copy/Programming/Javascript/Json Step2 (I extract the zip file in the directory I have just mentioned): unzip file.zip -d /home/paf/Copy/Programming/Javascript/Json – pablofiumara Nov 12 '13 at 1:10
  • 2
    unzip may be a default program. In other words, you may not need to install it. – noobninja May 31 '16 at 19:33
  • 2
    @Aevi Check man pages [-d exdir] An optional directory to which to extract files. – Zety Jan 11 '17 at 11:26
  • 3
    Make sure you extract to a directory, unlike tar archives, you may find many people include dozens of files in their root directory of their zip files, this can make a real mess!!! – Steve May 17 '17 at 6:13

You can simply use unzip.

Install it: apt-get install unzip

And use it: unzip file.zip

A more useful tool is 7z, which zips and unzips a range of compression formats, notably lzma, usually the protocol offering the highest compression rates.

This command installs 7z:

sudo apt-get install p7zip-full

This command lists the contents of the zip:

7z l zipfile.zip

This command extracts the contents of the zip:

7z x zipfile.zip
  • 4
    7z e does not keep the directory structure - 7z x does... – assylias Oct 23 '13 at 12:59
  • 1
    13.10 says 7z does not exist. I think it must sudo apt-get install 7zip – nitishch Oct 26 '13 at 19:04
  • 6
    I think the install command should be sudo apt-get install p7zip or sudo apt-get install p7zip-full You need the full version to get the 7z command. The full is also the only one who handles zip and other kinds of formats out of the two. – Automatico Oct 30 '13 at 20:15
  • could you clarify "A more useful tool"? Are you comparing to unzip? Could you provide any examples of features that make 7z more useful, and perhaps in which contexts 7z is preferred? – David LeBauer Sep 29 '15 at 22:17
  • For some unzip is more useful: easy to use and its Name to remember. – Shy Robbiani Jan 20 '16 at 7:25

You can use:

unzip file.zip -d somedir

to extract to yourpath/somedir

If you want to extract to an absolute path, use

sudo unzip file.zip -d /somedir

Using scripting tools: Perl and Python

Many answers here mention tools that require installation, but nobody has mentioned that two of Ubuntu's scripting languages, Perl and Python, already come with all the necessary modules that allow you to unzip a zip archive, which means you don't need to install anything else. Just use either of the two scripts presented below to do the job. They're fairly short and can even be condensed to a one-liner command if we wanted to.


#!/usr/bin/env python3
import sys
from zipfile import PyZipFile
for zip_file in sys.argv[1:]:
    pzf = PyZipFile(zip_file)


./pyunzip master.zip


#!/usr/bin/env perl
use Archive::Extract;
foreach my $filepath (@ARGV){
    my $archive = Archive::Extract->new( archive => $filepath );


./perlunzip master.zip

In case your destination is same as the source zip file, you can simply do:

unzip filename.zip
  • On Ubuntu 17.04, -d require for unknown reason. – 林果皞 May 4 '17 at 7:14

I prefer bsdtar to unzip/zip. For extracting, they are pretty similar:

bsdtar -x -f /one/two/three/four.zip -C /five
unzip /one/two/three/four.zip -d /five

However for zipping, bsdtar wins. Say you have this input:


and want this in the zip file:


This is easy with bsdtar:

bsdtar -a -c -f four.zip -C /one/two/three alfa bravo

zip does not have the -d option like unzip, so you have no way to achieve the above unless you cd first.

Here is the detailed description of options that I find useful:

Command: unzip -[option] zip-path.  
               -l List archive files.  
               -t Test archive files with cyclic redundancy check.  
               -u update the existing files.  
               -z archive comment.  

Here is the command in case you want to extract in present directory

unzip <source_file_path>.zip 

if you want to extract to a particular destination folder, you can use

unzip <sorce_file_path>.zip -d <destination_path>

if there a password you can also use -P

unzip -P <password> <sorce_file_path>.zip 

If the unzip package isn't already installed on your system, then run:

sudo apt-get install unzip
  • 2
    This sort of repeats what existing answers already said. – Sergiy Kolodyazhnyy Nov 1 '17 at 17:58

First of all you need to install unzip if it's not installed.

sudo apt-get install unzip

1 - If the File is in the same directory that the terminal is and you want to extract it in the same location.

sudo unzip file.zip

if the file is protected with password use :

sudo unzip -P file.zip

ans make sure it's -P not -p it's different option

2 - If the file is not in the same directory and you want to extract it in different directory the the terminal is . use :

sudo unzip path/filename.zip -d anotherOrSamePath

if you didn't use -d the file will be extracted to the location that terminal on.

And if there a password you can also use -P .

  • 1
    Please don't post screenshots of text. Copy the text and apply code formatting. – muru Aug 28 '17 at 7:00
  • note you don't need to use sudo use it only if needed i used it because the file is created by sudo so i wouldn't be able to edit it without sudo – Mahmoud S. Marwad Aug 28 '17 at 7:00
  • @muru it's from terminal , so if i copied it that will be meaningless i think . – Mahmoud S. Marwad Aug 28 '17 at 7:02
  • why would it be meaningless? What particular meaning does it gain from being a picture? – muru Aug 28 '17 at 7:03
  • showing that is the terminal and that what the output is . – Mahmoud S. Marwad Aug 28 '17 at 7:05

protected by Eric Carvalho Sep 30 '15 at 12:07

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.