How to Unzip in Linux [Linux Unzip] - Unzip command in Linux

Unzip is a utility used to extract files in Linux operating system. In this post, you will get unzip command in Linux with examples, unzip Linux, or how to unzip Linux-like information.

Updated: 24 Jan, 24 by Antoniy Yushkevych 6 Min

List of content you will read in this article:

Compression saves space by compressing data while archiving simplifies data transfer by merging several files or folders into a single file. For example, if we need to send five files over the internet, each of which is 100 MB, sending each file one by one could take longer. It would be much faster to copy the files if they are compressed to a size of up to 50MB and then archive all of them in a single file than if they are not compressed. Unzip is used to retrieve and decompress zipped files. Zip is the most commonly used utility for archiving and compressing files. So this guide will give you brief details about Linux Unzip, how to extract files in Linux, and Unzip commands in Linux. 

By default, Ubuntu systems come with zip and unzip packages. You can conveniently install these if not installed in your operating system. By using the Ctrl+Alt+T keyboard shortcut, open the Terminal. Then, type the following to load the zip:

$ sudo apt install zip

Run the following command in Terminal to install unzip:

$ sudo apt install unzip

You will be required to extract zip in Linux in the following circumstances:

  • Since zipping reduces the file size, it saves disc space.
  • Using e-mail to forward huge files
  • Increasing the speed of uploading or copying files
  • In order to conserve bandwidth

Don't miss out on this opportunity to simplify your Linux file size management. Say goodbye to frustration and hello to efficiency! Ready to leap? Click here to learn How to Find File Size in Linux and revolutionize your Linux experience.

When used without any options, the unzip command removes all files from the designated ZIP folder to the current directory in its most basic form.

Let's presume you downloaded an installation ZIP file as an example. Simply execute the following command to unzip this file to the current directory:


ZIP archives do not support Linux-style ownership details. The person who executes the command owns the collected data.

The folder where you're extracting the archive in zip format must have write permissions.

The output of the unzip linux command

Unzip prints the names of all the files downloaded by default, as well as a list when it's finished.

To prevent these messages from being printed, use the -q option.

unzip -q

How to Unzip a ZIP file to a New Directory?

Using the -d option to unzip a ZIP file to a separate directory from the present one:

unzip -d /path/to/directory

To unzip an installation folder to the /var/xyz/folder, for example, run the below given commands in linux:

sudo unzip -d /var/xyz

We're using sudo command above because the user we're logging in as normally doesn't have write access to the /var/www directory. When you use sudo to decompress ZIP data, the root owns the extracted files and folders.

How to Unzip password-protected files?

If you want to unzip a protected file that is secured by a password, use the unzip command with the -P option and the required password for that file:

unzip -P ********(your password)

Using the command line to type a password is vulnerable and should be avoided. Extracting the file normally without giving the password is a more safe choice. Unzip will ask you for the password if the ZIP file is encrypted:




[] file.txt password: 

Unzip can be used for all encrypted files as long as the password is valid.

Unzip a file by excluding those files that we don’t want to unzip:

Using the -x alternative accompanied by a space-separated list of archive files you wish to remove from being extracted to exclude individual files or folders from being extracted:

unzip -x file1-to-exclude file2-to-exclude

Except for the.git directory, we remove all files and folders from the ZIP folder in the following example:

unzip -x "*.git/*"

Unzip command will overwrite the Existing Files

Let's pretend you've already unzipped a ZIP file, and you're repeating the process:


Unzip will prompt you to overwrite only the existing file, all records, skip the extraction of the existing file, skip the extraction of all files, or rename the current file by default.



replace wordpress/xmlrpc.php? [y]es, [n]o, [A]ll, [N]one, [r]ename:

Using the -o method if you want to erase current files without prompting:

unzip -o

With this alternative, proceed with caution. Changes to the files will be missed if you make them.

Unzip command Without Overwriting the Existing Files

Assume you've already unzipped a ZIP file and modified certain files, but you've even erased a few files by mistake. You want to retain the updates and recover the files removed from the ZIP directory.

Using the command -n to force unzip to skip the extraction of a file that already exists:

unzip -n

How to Unzip multiple files?

Regular expressions should be used to balance different files.

If you have several ZIP files in your current working directory, for example, you can unzip all of them with only one unzip command:

unzip '*.zip'

It's worth noting that the *.zip is enclosed in single quotes. If you don't quote the statement, the shell will enlarge the wildcard character, resulting in a mistake.

How to List the Zip File Contents together?

Using the -l option to list the contents of a ZIP file:

unzip -l

It is a commonly used command to list and extract compressed ZIP files. The zip command in Linux is used to compress the files. When someone sends you a zip file, then you can unzip the Linux file to see the content. Hence we have covered different operations related to unzip and tried to help you to understand how each command varies depending on the usage.

People are also reading:

Antoniy Yushkevych

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at
user monovm

Prof. Jalon Heidenreich

2024, Jul, 24

This guide is incredibly thorough and practical for anyone looking to manage their files more efficiently in Linux. It simplifies what can sometimes feel like a complex task into easy-to-follow steps. The inclusion of various unzip scenarios, such as handling password-protected files and excluding specific files, makes this a one-stop resource. Thanks for breaking it all down so clearly!