Linux Commands

How to unzip a zip file in Ubuntu

Zip is a commonly used file format for integrating several files into one file. This minimizes file size and makes transfer and storage easier. To use these files, we need to extract them from any location on disk using some tool. The zip files can be extracted on different operating systems with ease. Here we will discuss the unzipping of zip files in Ubuntu (Linux OS).So, if you want to easily unzip a zip file in Ubuntu follow the procedure mentioned below:

How to unzip a zip using “unzip” command in Ubuntu 20.04

By default, the unzip command is installed on your Ubuntu PC, but if it is not installed then install it by the command mentioned below:

$ sudo apt install unzip

On my PC it is already installed. You must have some file with “.zip” extension in any directory of your PC. Now, move to directory in which your zip file is present by using the change directory “cd” command:

$ cd [Directory-Name]

How to unzip a zip file in the same directory in Ubuntu 20.04

After successful installation of the “unzip” command, you can easily unzip a zip file. You must have some file with “.zip” extension. Follow the syntax mentioned below to extract the zip file:

$ unzip [FileName].zip

In the syntax you have to replace [FileName] with the name of your zip file. Like my zip file name is “”, now the above syntax will be:

$ unzip

Now my zip file will be extracted to the Downloads directory as demonstrated in the image below:

How to unzip a zip file in a different directory in Ubuntu 20.04

To unzip a zip file in any directory of our own choice rather than extracting it in the same directory it is present, follow the syntax given below:

$ unzip [FileName].zip -d /[Directory-Path]

In the above syntax replace [FileName] with your zip filename as we did previously and replace directory path with the directory path where you want to extract the zip file. For instance, I want to unzip on desktop, the command would be:

$ unzip -d /home/alishba/Desktop

Now my file will be extracted on the desktop:

How to unzip a zip file with suppressed output in Ubuntu 20.04

While extracting a zip file, it displays the names of all files in it and then a description when it is finished. Use the “-q” flag to avoid this:

$ unzip -q [FileName].zip

Like I wanted to unzip “” using “-q” flag, so replace [FileName] in the above syntax with your own zip filename:

$ unzip -q

How to extract a zip file while excluding files in Ubuntu 20.04

While extracting a zip file, you can only extract the files you required and exclude the other files from the zip file. For this you have to use the “-x” flag with unzip command and space between filenames:

$ unzip [FileName].zip -x*Filename1*” “*Filename2*

In the above syntax replace [FileName] with your zip filename and “Filename1” and “Filename2” with the names of files you want to exclude while unzipping of your zip file and you can exclude as many files as you want following the syntax.

Here my zip Filename is “” and Filename1 is “file1.txt” and Filename2 is “file2.txt” so syntax will be:

$ unzip -x*file1.txt*” “*file2.txt*

Now we can check the extracted zip file whether the mentioned files are excluded or not:

So, we can see that “file1.txt” and “file2.txt” are excluded during extraction.

How to overwrite the existing extracted file in Ubuntu 20.04

If you are extracting some zip file and it’s extracted version is already present in that directory then it will ask your permission to overwrite that file:

$ unzip [FileName].zip

Replace [FileName] with the file filename you want to extract:

$ unzip

Use “-o” flag for overwriting already present extracted zip files without producing a dialogue:

$ unzip -o [FilenName].zip

Replace [FileName] with your own filename; my zip filename is “”:

$ unzip -o

How to list the content of a zip file in Ubuntu 20.04

The “-l” flag is used to list the content of a zip file:

$ unzip -l [FilenName].zip

Replace [FileName] with your zip filename, here I am listing the content of the “”:

$ unzip -l

How to unzip a zip file avoiding overwriting of files in Ubuntu 20.04

Use the “-n” flag to avoid overwriting of files which are already extracted from a particular zip file; follow the below mentioned syntax:

$ unzip -n [FileName].zip

I will be replacing [FileName] with “”:

$ unzip -n

How to unzip multiple files in a directory in Ubuntu 20.04

If you want to unzip all the zip files from a directory at same time then run the below mentioned command:

$ unzip*.zip’

You can check the number of zip files in directory by below mentioned command:

$ ls [directory_name]

Here I am going to extract all the zip files in Downloads:


For compressing several files into the single file at the same location we use zip utility. We need to unzip the zip file to utilize the items in it. In this article we discuss various methods to extract zip files such as extraction of files in the same directory they are present, on different locations of your choice, extraction of multiple files of the same directory etc. This write-up will surely assist you in understanding the unzip command in Ubuntu.

About the author

Shehroz Azam

A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.