How to Unzip a ZIP File in Ubuntu / Linux

December 2, 2019


If you downloaded a file that ends in .tar.gz or .zip, this indicates that it has been compressed.

This guide will walk you through unzipping a zipped file in Ubuntu 18.04 or Ubuntu 20.04.

How to unzip a file in Linux Ubuntu.


  • Access to a terminal window/command line (Ctrl-Alt-T)
  • Zip/unzip utility (included by default)

How to Install the Zip and Unzip Utility in Ubuntu

Ubuntu distributions usually include the zip and unzip utilities. If for some reason yours does not, use the following command to install it:

sudo apt-get install zip unzip

The output in our example confirms that the latest version is already installed:

Install the zip and unzip features command example

Unzip a File Using the Command Line

This guide assumes that you’ve already downloaded a file that has been zipped, and that you know where it’s located. Let’s assume that we have downloaded a file called to the /home/user/Documents/ directory.

Start by opening the terminal. By default, you should start in the /home/user/ directory.

To list the contents of the directory you are currently viewing enter:


Ubuntu will color-code different entries.

List of file and folders in the Home directory

Directories are colored blue, regular files are colored white (the same as the text you type).

To change to the Documents directory, use the command:

cd Documents

As the folder only contains the file, the output looks like this:

Content of Documents folder after unzipping

Note: Observe the capitalized D in Downloads. It is necessary to type the name of the directory exactly as you see it on the screen. Linux treats /Downloads and /downloads as two different directories.

Enter ls again. You’ll get a different listing – the content of the Documents folder.

To unzip the file, enter the following:


The system will decompress the file, and place a copy of its contents in the /Documents directory.

Note: Normal copying conventions apply. If the file contains a file named document.txt, and a file with that name already exists in the target directory, the system will ask if you want to overwrite the existing file.

Other Linux Unzip Commands

The zip and unzip commands can be used with additional options to have more control over how they work. Here are just a few common ones.

How to Unzip Multiple ZIP Files

For example the folder /Documents/zipped has several files zipped in it. Use the cd command to change to that directory:

cd zipped

To unzip all the files in that directory.:

unzip “*.zip”

The * sign is a wildcard, which means “any number of any characters.” So, any file that ends in .zip would be found and unzipped by entering this command.

How to Test if a ZIP File is Valid

You can use the –t option with the zip command to test the file first. Enter the following:

unzip -t

This is useful if you think the zipped file has been damaged or corrupted.

The screen confirms that all the files are OK and that no errors were reported.

The system will tell you if it detects any errors.

How to Exclude Files When Unzipping a ZIP File

Some zip files have several different files included in them. You can extract all of them, or you can exclude some of them.

To exclude a particular file:

unzip –x a_particular_file.txt

This would prevent the file a_particular_file.txt from being extracted from the zip file.

How to List the Contents of a Zip File

To view a list of the contents of a zip file use the -l option with the zip command:

unzip -l

The output lists the files within the folder.

List of files within

Extract a ZIP File to a Different Directory

To specify that you want to unzip the files to a different destination than the directory you are in,  type the command:

unzip –d /home/user/destination

The –d switch tells the system to put the unzipped files somewhere else. You can substitute the path to a location of your choice for /home/user/destination.


This article has explained how to unzip and access the content of zip files in Ubuntu Linux.

Was this article helpful?
Vladimir Kaplarevic
Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative technologies in others by providing practical advice and using an engaging writing style.
Next you should read
How to Remove (Delete) a File or Directory in Linux
December 2, 2019

This article lists the most commonly used commands and tools to remove unwanted files and directories from Linux.
Read more
How to Create a File in Linux Using Terminal/Command Line
November 7, 2023

Creating a file in Linux might seem straightforward, but there are some surprising and clever techniques.
Read more
How to Install and Use Nano Text Editor Commands in Linux
April 12, 2019

Nano is a simple, modeless, WYSIWYG command-line text editor included in most Linux installations.
Read more
How to Save a File in Vi / Vim & Exit
September 22, 2022

Vim (Vi IMproved) is a well-known, open-source text editor for Linux or Unix systems. It is a powerful and versatile...
Read more