Unzip Command in unix | Unzip Command in unix with Simple Examples

Unzip file in unix

Unzip Command in unix :

In my previous articles i have given different commands of unix with real world industry examples.In this article i will try to explain you one of the useful command in unix – Unzip Command in unix. The Unzip Command in unix is very useful as well as frequently used command.The developers are well as support engineers need to Zip and unzip the files for proper memory utilization. So Unzip Command in unix is most important command.

As i explained you before that zipping of file is really very easy task. But when it comes to unzipping files it is bit complex task as compared to zipping of the file in unix operating system. So it is very important to study the Unzip command in unix with its different options which will be used widely for unzipping the zipped files in unix. I will explain the multiple ways to Unzip the zipped files using unix command prompt.

Unzip Command in unix syntax and examples :

Before discussing about the multiple examples of Unzip Command in unix ,let us first check the way to install Unzip command in Linux Operating system,

Install Unzip Command on RedHat , Fedora or Centos :

$ Yum install unzip

Install Unzip Command on Ubuntu and Debian  :

$apt-get install.zip

These are above multiple ways to install unzip command in linux operating system.

Let us start with very basic syntax of Unzip command in unix.

Syntax : 

Unzip Filename

The Unzip command is used for decompressing the zip file.The above syntax will be used to unzip or decompress a single file.

Example 1 : Decompress Single Zip Folder

If user want to unzip the files from zip file named Project.zip.User need to use the command named Unzip.

$Unzip Project

The above command is used to decompress the single file.


Example 2 : Decompress Multiple Zip Folders

There is no provision to decompress multiple zip folders at a same time. If you have project .zip file which has 3 different segments like, project1.zip, project2.zip and project3.zip. You need to unzip or decompress all the files at a time.

$Unzip “Project1.zip” “Project2.zip” “Project3.zip”

With using above command in unix user will get error. User can not decompress multiple zip files using above command.

Error :

Archive : Project1.zip caution: Filename not match “Project2.zip”


To unzip multiple zip files at a same time use following syntax .

Syntax : 

$Unzip “*.zip”

The above command is used to unzip each and every zip file in current folder or current directory.So make sure that you are in the directory where you need to unzip all the files.

Example 3 : Decompress all the files excluding some of the files

Lot of time there should be requirement like user need to exclude the specific file from the zip folder.The Linux provides facility to exclude a single file and unzip all other files. -x option of unzip command is used to exclude specific file or specific type of files. There should be two scenarios in this

3.1. Exclude Specific types of files :

If user want to exclude .txt files from Project.zip folder while extracting. In this scenario following syntax is useful

Syntax :

$Unzip Filename.zip -x “*.Fileextension”

Example :

$Unzip “Project.zip” -x “*.txt”

The above command will decompress all other files with excluding all the .txt files

3.2. Exclude the Specific file :

If user wants to exclude only specific file. Lets say from Project.zip folder user need to exclude password.txt file following syntax is useful

Syntax :

$Unzip Filename.zip -x “Filename.Fileextension”

Example :

$Unzip “Project.zip” -x “*Password.txt”

The above command will exclude the password.txt file and decompress all other files except that.

Example 4 : Extracting .zip file to other location

Unix provides provision to unzip the zip folder to other directory. -d option is used to copy or extract the zip file to other location.

Syntax : 

$Unzip Filename.zip -d  Pathwheretoextract

If user want to extract project.zip folder to path named project/bin/project1 then following command is useful.

Example :

$Unzip project.zip -d  project/bin/project1

All the files from project.zip is extracted to project1 folder.

Example 5: See the Zip folder contents

Unix provides provision to see the contents in the zip folder before decompressing it.-l option of unzip command is used for the same. -l stands for list of files.-l option shows ,

name of file,date created,time created and length in bytes.

Syntax :

$Unzip -l Filename.zip


$Unzip -l project.zip

Example 6: Checking zip file validity

Unix provides facility to check the validity of zip file.User needs to use -t option of unzip command.

Syntax :

$Unzip -t Filename.zip


$Unzip -t project.zip

If your file is valid file then you will get message as ‘OK’ and no errors detected in compressed data of Project.zip.


Unzip Command in unix

Example 6: Checking details of zip folder

If you want to check the details of zip folder user needs to use the -v option of unzip command.

Syntax :

$Unzip -v Filename.zip


$Unzip -v project.zip

The above command will give you information about the filename.The information contains length in bytes,method,size,compression percentage,date and time created and name of the file.

Example 7 : Decompress files without making folders or directories

When user unzip the zip file different folders are created. Just an example if user unzip the file project.zip and if there are 3 different folders as project1,project2 and project 3 then after unzipping the zip file you will get the 3 different folders, There are some requirements where user dont want to create the folders.

Unix provides j option of unzip command which will not create directories while unzipping the main zip folder.

Syntax :

$Unzip -j Filename.zip


$Unzip -j project.zip

Example 8 : Decompress files without overwriting

Sometimes user do not know about which files are important and which are not. User dont want to overwrite the files after unzipping it.-n option of unzip command is used to extract the files without overwriting it.

Syntax :

$Unzip -n Filename.zip


$Unzip -n project.zip

Example 9 : Decompress password protected zip files

So many times the zip files are password protected. To deal with this scenario user needs to use -p option of unzip command. User needs to give password of the file while using this option.

Syntax :

$Unzip -p password Filename.zip


$Unzip -p Zip@3333 project.zip

In above example we have used the -p option of unzip command. The password of Project.zip is Zip@3333.


These are above some important options of using Unzip command in unix. These options are really important for programmers as well as support engineers. If you like this article or if you have any concerns with this article kindly comment in comments section.

About Amit S 146 Articles
Oracle Consultant with Vast Experience in Oracle BI and SQL PLSQL Development

Be the first to comment

Leave a Reply

Your email address will not be published.