How to Unzip a file in Linux

A Zipped/Zip file is a file archiving method and format. The Zip file is a container which has the actual files of interest “nested” inside. We will unzip a file using CLI within a Debian or Ubuntu based distro;

We will use “Unzip”

First check if you have Unzip installed by inputting unzip –version. If it’s already installed, you will see details of the program such as version, command switches etc. You will get an error if it’s not installed, in which case install by inputting sudo apt install unzip

How to Unzip a ZIP file
The unzip command extracts all files to the current directory where the ZIP file is stored/located.

Example; Here is a screenshot of Cyberchef which is downloaded as a Zip file

To unzip this file to the current directory, we need to run the following command unzip If the zip file name is long/complicated then right click on the file, select Properties and copy the file name which you can then paste into Bash. Ensure you are in the correct/same folder as your Zip file (establish the file path and cd into it)

The output in Bash and the file directory will show as below. The Zip folder has now been unpacked


The extracted files are owned by the user that runs the command and your user credentials will need to have write permissions applicable to the directory where you want to extract the ZIP file.

To explore all available switches using unzip, simply type unzip –help or unzip -hh

Here are some switches you may find useful;

List the content of the Zip file before or after extracting

Switch is -l which will simply list out all the files contained within the archive or -v for verbose output

Unzip a Password Protected ZIP file
Switch is -P p which lets you input a password to decrypt a file

unzip -P PasswOrd

Typing a password CLI can be insecure. Ideally just extract the file normally (without providing the password). If the ZIP file is encrypted, unzip will prompt you to enter the password

unzip -n

Unzip Multiple ZIP Files
You can use regular expressions (RegEx) to match multiple archives. For example, if you have multiple ZIP files in your current working directory you can unzip all files using only one command

unzip ‘*.zip’

Note the single quotes around the *.zip. If you forget to quote the argument, the shell will expand the wildcard character, resulting an error message.

List the Contents of a Zip File
To list the contents of a ZIP file, use the -l option:

unzip -l