Zip is one of the most popular ways to create compressed files. It is also one of the oldest compressed file formats. Since it is widely used, you will come across zip files often.
In a previous tutorial, I showed how to compress a file in Linux. In this article, we will learn how to unzip a zip file on Linux.
How to unzip a Zip File on Linux using Command line
Unzip is the command used to decompress zip files. Unzip is not installed by default in most Linux distributions, but you can easily install it through the package manager.
Install unzip on Ubuntu and Debian
sudo apt install unzip
Install unzip on CentOS and Fedora
sudo yum install unzip
How to extract files with unzip
Using the unzip command in Linux is very simple. In the directory where you contain the zip file, use the following command:
unzip file.zip
Unzip the zip file to another folder
To extract the ZIP file to a directory other than the current directory, use the -d option:
unzip filename.zip -d /path/to/directory
For example, to extract the WordPress latest.zip file to the /var/www/ directory, you would use the following command:
sudo unzip latest.zip -d /var/www
View the contents of the zip file instead of extracting it
You can check the contents of a zip file without extracting it with the -l option.
unzip -l file.zip
The displayed results have the form:
Archive: file.zip
Length Date Time Name
--------- ---------- ----- ----
154913 2020-04-13 11:55 house.jpg
623 2020-04-23 14:56 java.log
--------- -------
155536 2 files
Extract the zip file containing the password
To extract a password protected file, enter the zip command with the -P option followed by the password:
unzip -P PasswOrd filename.zip
Entering a password on the command line is not secure. So the safer way is that you will unzip the file normally without providing the password. If the ZIP file is encrypted, unzip will prompt you for a password:
unzip filename.zip
Output:
archive: filename.zip
[filename.zip] file.txt password:
Extract multiple zip files simultaneously
You can use regular expressions to match multiple files at once.
For example, if you have a lot of ZIP files in the current working directory, you can extract all the files with just one command:
unzip '*.zip'
Note that you need parentheses around *.zip. Otherwise, you will get an error.
See more: How To Zip Files On Linux
How to decompress Zip File on Linux
You don’t need to use a terminal to extract files if you are using Linux Desktop. Here I am using Ubuntu 20.04 version, but this decompression process is similar to other Linux distributions.
Open the folder containing your zip file. Right-click on the file and select Extract Here.

Unlike the unzip command, the Extract Here option will create a folder with the same name as the archive and all the contents of the archives are contained within this newly created folder.

If you want to extract to a directory other than the current directory, select Extract to navigate to the directory you want.

If you want to preview the contents of the zip file, select Open With Archive Manager


In case the zip file has a password protected setting, you will need to open the zip file with Archive Manager as above then select Extract in the upper left corner, a window will appear asking you to enter the password:

It is done. You have successfully extracted the zip file in Linux. Hope this little tip will help you quickly extract zip files in Linux operating systems.