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.
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:
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 test.zip 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.
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:
As the folder only contains the test.zip file, the output looks like this:
Note 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 lsagain. You’ll get a different listing – the content of the Documents folder.
To unzip the test.zip file, enter the following:
The system will decompress the test.zip file, and place a copy of its contents in the /Documents directory.
Normal copying conventions apply. If the test.zip 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:
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.