unzip file in linux

How to Unzip File in Linux

Zip is a popular compression format for files & folders in Windows & Linux. Its compressed files have .zip extension. Uncompressing .zip files is known as unzipping files. Sometimes you may need to unzip one or more files & folders in Linux. In this article, we will learn how to unzip file in Linux. You can use these steps on any Linux distribution.

How to Unzip File in Linux

Here are the steps to unzip file in Linux.

1. Install Unzip

In most Linux systems, you will not find unzip utility to be installed by default. So you will need to install them with the following command.


$ sudo apt-get install unzip


$ yum install unzip

Please note, zip and unzip are different utilities and need to be installed separately. If you need to zip files & folders then you need to install zip by adding it to the above commands. Unlike tar, which does bot compression and decompression, zip only does compression while unzip does decompression.

2. Unzip file

Once you have installed unzip, you can easily unzip file with the following command. Here is the command to unzip data.zip file.

$ unzip data.zip

If the above command gives an error ‘permission denied’ use sudo keyword at the beginning of command or run the command as root user.

Please note, if you only specify the filename with unzip command, it will look for the file in your present working directory, and give an error ‘file not found’ if it is unable to find the file. So it is advisable to mention the full path in unzip command.

$ unzip /home/ubuntu/data.zip

Unzip will extract all files & folders in specified file and place them in your present working directory.

3. Unzip multiple files

If you need to unzip multiple files, you can specify them one after the other in a space-separated manner, as shown below

$ unzip data.zip users.zip project.zip

If will extract all files & folders to your present working directory.

You can also use wildcard characters such as * to extract multiple zip files. Here is the command to extract all zip files in your present working directory. Please note to add quotes around *.zip below.

$ unzip "*.zip"

4. Unzip to specific folder

So far we have seen all examples that extract zip files to our present working directory. If you want to extract file to specific folder, you can do so with -d option. Here is an example to unzip files to /home/projects folder.

$ unzip data.zip -d /home/projects

Again, if you get ‘permission denied’ error, add sudo keyword at the beginning of your command.

5. Exclude files from extraction

If you want to extract specific file such as file.txt from extraction, use -x option as shown below.

$ unzip data.zip -x file.txt

6. List contents of zip file

Sometimes you may want to see the contents of zip file without actually extracting it. You can do so with -l command.

$ unzip -l data.zip 

In this article, we have learnt different ways to unzip file in Linux. You can use these commands on almost every Linux system.

Also read:

How to Uninstall Package in CentOS
How to Limit Bandwidth & Connection in Apache
How to Remove Local Untracked Files in Git
How to Create Menu with Submenu in Shell Script
How to Delete File in Git Repository

Leave a Reply

Your email address will not be published.