Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

8 Answers 8

up vote 247 down vote accepted

If you want to extract to a particular destination folder, you can use:

unzip file.zip -d destination_folder
share|improve this answer
59  
and sudo apt-get install unzip if needed. –  Steve Bennett Jan 16 '13 at 0:37
3  
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 –  Wolter Hellmund May 26 '13 at 19:13
    
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
    
Is there also a "...and visit that folder in terminal" possibility of some kind? –  Dualinity Feb 21 at 11:06
    
Does this unzip file.zip -d destination_folder will also give all directory which start with .git and files . as start name ,Because this are hidden in Ubuntu .IF it will not extract them then how i can unzip them all from my zip file. –  Herry Apr 5 at 5:18

It is simple use unzip

unzip file.zip
share|improve this answer

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
share|improve this answer
    
7z e does not keep the directory structure - 7z x does... –  assylias Oct 23 '13 at 12:59
    
13.10 says 7z does not exist. I think it must sudo apt-get install 7zip –  hatter Oct 26 '13 at 19:04
2  
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. –  Cort3z Oct 30 '13 at 20:15

You can use:

unzip file.zip -d /Dir

or maybe if you want extract to a folder of the system you can do this:

sudo unzip file.zip -d /rootDir
share|improve this answer

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

unzip filename.zip
share|improve this answer

Unzip command will not work until you Install unzip. to install unzip just run below command, it works for me.

$ sudo apt-get install unzip
share|improve this answer

Here is the detailed description with options that i find useful:

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

Please install the unzip first using this command:

            $ sudo apt-get install unzip

Then go to zip file directory using cd command

            cd /path/to/dir

then type this command:

           $ sudo unzip file.zip

You can also unzip a file into a directory of choice by using the '-d' flag:

           $ sudo unzip file.zip -d /path/to/dir
share|improve this answer
    
Why would you use sudo to unzip without knowing if it's necessary? –  muru Nov 19 at 8:31
    
hi muru , you are right there are no need to use sudo command but if i wanat to unzip file in my home user directory then we will have to use sudo command to get the permission for the same. For eg . if i try to unzip my file in /var/www folder then without sudo command i could not extract my zip file.So there is no lose of user if he/she writes command with sudo .it works in every case. –  user834799 Nov 19 at 8:59
    
Then you should state that, like this answer has. –  muru Nov 19 at 9:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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