Ubuntu Unzip Command: Unzip a Zip File on Linux

A zip file is an archive file format used to compress data using a lossless algorithm. Using the .zip file extension, you can compress more than one directory or folder in a single archive file. 

This file compression method is an efficient way to transfer files between different computer systems without the loss of any data. If you want to use an archive on your system, you can extract a zip file using different utilities. For instance, to unzip a zip file on Linux, the “unzip” utility is used, which allows you to extract zip files using different options. 

In this article, we will demonstrate how to unzip a zip file on Linux. To do so, We will be using the Ubuntu 22.04 Jammy Jellyfish distribution to implement the Ubuntu unzip command to extract a zip file.

How to Unzip Files in Ubuntu? (Ubuntu Unzip File)

You can unzip files in Ubuntu 22.04 using two different methods:

  1. Unzip a zip file using the terminal
  2. Unzip a zip file using GUI

Method 1: Unzip a Zip File Using the Terminal

The Ubuntu unzip command is useful for extracting all types of zip files. The unzip utility is installed by default on most of the Linux distributions, including Ubuntu 22.04. However, if this utility is not preinstalled on your system, you can install it using the command line. 

Open the terminal using “Ctrl+Alt+t” with sudo privileges and run the below command to install the unzip utility on Ubuntu 22.04:

$ sudo apt install unzip

ubuntu unzip command: unzip a zip file on linux

Ubuntu Unzip Command Syntax

The basic syntax of the unzip command is given below:

$ unzip [zip_file_name].zip

In the above syntax, the unzip is a Linux command that you can use after installing the unzip utility on your system. To do that, type the file name with the .zip extension

Unzip a Zip File in the Same Directory on Linux

To unzip a zip file in Linux, navigate to the directory in which your zip file is located using the “cd” command

$ cd directory_name


For example, let’s say you have a zip file in your Downloads directory. Now, extract the file in the same directory using the Ubuntu unzip command:

$ unzip testfile.zip

ubuntu unzip command: unzip a zip file on linux


The above command will unzip the zip file “testfile.zip” in the system’s Downloads directory. You can also verify it to list all files on the terminal using the “ls” command.

$ ls 

ubuntu unzip command: unzip a zip file on linux

Unzip a Zip File Into a Different Directory on Linux

If you want to unzip a zip file to a different directory instead of extracting files in the same directory, use the unzip command with the “-d” option. 

$ unzip testfile.zip -d /path-to-directory

For example, let’s say you want to unzip a file in the Documents directory instead of extracting files in the Downloads. In this case, you will use the unzip command as follows:

$ sudo unzip testfile.zip -d /home/samreena/Documents

ubuntu unzip command: unzip a zip file on linux

Verify it after executing the above command, and you will notice that the zip file is extracted in your Documents directory on your Ubuntu system. 

“It is important to note that users should have read/write permissions to unzip a zip file to a different directory on the Linux system.”

List Zip File Content

You can list the zip file content. To display content or sub-files of a zip file during the unzip process, use the “-l” switch with the unzip command.

$ unzip -l testfile.zip

The above command will list the zip file content on the terminal.

ubuntu unzip command: unzip a zip file on linux

Unzip a ZIP File to Suppress the Description

When you unzip a file in Linux using the unzip command, its description, including file names or summary, is displayed on the terminal. If you don’t want to print the file names during the execution of the unzip command, use the “-q” option:

$ unzip -q file-name.zip

The above command will not show the zip file description on the terminal during the unzip files. 

ubuntu unzip command: unzip a zip file on linux

Unzip Multiple Zip Files

You can unzip multiple zip files as well in Linux. To unzip multiple files, you can use regular expressions that match the archive file format in a directory with “*.zip.” Use the below-given command if you would like to extract multiple zip files in Linux:

$ unzip ‘*.zip’

ubuntu unzip command: unzip a zip file on linux

Exclude Files From Unzip a ZIP file

You can also exclude the files that you don’t want to extract during the unzip process. By doing this, the unzip will extract only the selected remaining files and exclude the rest from the output. 

To exclude files from extraction, use the “-x” option with the unzip command and specify the file names that you don't want to extract from a zip file. You can do it using the following command:

$ unzip [FileName].zip -x “*file-name1*” “*file-name2*”

Overwrite Existing Zipped Files

Suppose you have already unzipped files, and you accidentally executed the unzip command again. In this case, it will ask you to overwrite the existing files. If you want to overwrite the previous files without generating any prompt on the terminal, use the option “-o” with unzip command:

$ unzip -o file-name.zip

Execute the above command with extra care because, in case of any error or mistake, you can lose your original data.

If you don’t want to overwrite the existing unzipped files, use the option “-n” with the unzip command.

$ unzip -n file-name.zip

The above command will forcefully skip the files that exist or are already extracted.

Unzip or Extract Password-Protected Zip Files 

Using the unzip command, you can also extract password-protected zip files or archives. To unzip a password-protected zip file, use the following command:

$ unzip -P Password file-name.zip

It is recommended that you avoid using a terminal to extract password-protected files because it is not secure.

Method 2: Ubuntu Unzip File using GUI 

You can unzip a zip file in Linux using Gnome desktop by following these steps:

  1. Open the file manager and navigate to the directory where the zip file is stored.
  2. Select and right-click on the zip file.
  3. Choose the “extract here” option to unzip a zip file in the current working directory.
  4. If you want to unzip files in a different directory, choose the “extract to” option. 

ubuntu unzip command: unzip a zip file on linux

  1. Specify the path to the folder where you want to unzip or extract files and click on “Select.”

ubuntu unzip command: unzip a zip file on linux

Conclusion

In this tutorial, we demonstrated how to unzip a zip file on a Linux system. Also, we explored how Ubuntu unzip files facilitate users to list and unzip the compressed files. What’s best about this is that the unzip command can also be used for file extraction by those who are using services like VPS hosting. Thanks for reading!