Javatpoint Logo
Javatpoint Logo

How to unzip files in Linux?

Generally, almost all files like documents, media files are shared in the zip format to avoid several types of damages or theft. One can also set the password to protect the files from unnecessary access, which also helps protect the documents' confidentiality. Still, new users or that are not familiar enough with computers or do not have an IT background face many difficulties while working with these types of files, such as opening the zip files, compressing files, etc.

In this tutorial, we will learn how to open the zip files in Linux based operating systems (Ubuntu). Before going further, we need to know how to identify the zip files first. If the downloaded files (or target file) contain .tar.gz or .zip in extension, it means that the file is a type of zip file. To access the contents of a zip file, we need to extract that file, after which we can easily access the content of that file.

Prerequisite:

  • Access to the terminal window or command line (Ctrl-Alt-T)
  • Administrator password
  • Zip/unzip utility

How to install Unzip utility in the Ubuntu?

To unzip a zip archive file, you must have the unzip package installed in your system. However, almost all modern Linux distributions come with unzip support, but there is no harm in verifying it to avoid nasty surprises later in case of you are not sure about it. In Ubuntu and Debian based distributions, one can use the following given steps to install unzip. If it's already installed on your operating system, it will notify you about it.

Step 1: Open the terminal and types the following given command and press enter as shown in the given output:

Command :

Output

How to unzip files in Linux

Once you install the unzip package in your operating system, now you can zip and unzip the files as per requirements.

There are two ways available through which zipped files can be unzipped in the Linux operating system; here, we will discuss both the methods (or processes), along with practical.

Let's understand the above methods in details.

Unzip files using the Linux terminal

The following steps will help us to work with zipped files in Linux and show how to zip files without reducing their quality.

Steps to Unzip files in Linux:

Step 1 - The process of unzipping files in Linux is very straightforward. First of all, open the terminal and go to the directory, where we have our zip file as shown in the given image:

How to unzip files in Linux

Step 2 - Now use the "ls "command to view all files stored in that directory and use the following command to unzip the zip file.

Let's understand the working of this command by following example:

Suppose we have a zipped file such as "samplefile.zip" stored in our download directory. To unzip the "simplefile.zip," we need to open the terminal and go to the download directory using the following commands:

Example

How to unzip files in Linux

Step 2 - Now type the command <unzip "samplefile.zip"> and press enter, and once the file gets unzipped, you can access the content of your unzipped file as shown in the given image:

How to unzip files in Linux

How Zip files in Linux?

The process of converting your standard files into zipped format is slightly different than what we have done earlier. To convert a file (e.g., samplefile.mpg), we have to go to the directory where the file is stored in your operating system. Once you reach the directory, you can use the following command to convert that file into the zipped format.

Command:

To see how this command works, consider the following given example:

How to unzip files in Linux
How to unzip files in Linux

We can also provide the zip file path we want to unzip instead of going to the directory. To do that, consider the following given steps:

Step 1. Open the terminal and type the following given command

Command:

It will show the following output.

In general, this command seems very handy to use. However, in some cases, the user may face a slightly bigger problem while using the above command if he does not use it carefully. The main problem with this command is that it usually extracts all the contents of that particular zip file in the current directory or folder, which is not good, at least in some cases.

Unzip files to the Directory

The above problem can be avoided easily by unzipping the target file to an individual directory instead of extracting it into the current directory. This way, our all extracted files will be stored in the specified directory. In some situations where the directory specified by the user does not exist, it will also take care of that by creating the directory with the mentioned label.

Let see how to unzip a file to a particular directory

To unzip a zipped file to a particular folder or directory, one can use the following instructions:

Step1: Open the terminal and go the directory where your compressed or zipped file is stored. Once you reach that directory, type the following given command in the terminal

Command :

To understand how this command works, consider the following given example:

Suppose you have a zipped file (e.g., samplefile.zip ) that you want to extract in a particular different directory (e.g., Akash).To do that, you need to specify the directory or address of the directory in which you want to extract your zipped file. Hence our command will be looks like the following ones:

Command

<unzip samplefile.zip -d \Akash>

Output

How to unzip files in Linux

Now all the content of the samplefile.zip will be extracted to the user's specified directory.

2. Unzip files via the Graphic User Interface:

This method is absolutely simple for all users, even for beginners. It just looks like that of the window's process of extracting zip files. To unzip the zip files via the graphic user interface, follow the instructions given below.

Step 1. Open the file explorer in your Linux operating system:

How to unzip files in Linux

Step 2. Now go to that folder, where you stored zipfile (e.g., textfile.zip) and select it, as shown below:

How to unzip files in Linux

Step 3. After selecting the zipped file, click the mouse's right button to view more options:

How to unzip files in Linux

Step 2. Now click on the option "Extract Here" or "Extract to" as per requirements. We want to extract that file in the current folder, then click on the "Extract" option.

How to unzip files in Linux

Step 4. In case you want to extract that file in a different folder, then you can use the "Extract to" option as shown below:

How to unzip files in Linux

Step.5 After clicking on the "Extract to" option, a new window will be opened in which you have to specify any directory where you want to store the content of the file. Once you select the directory or folder, click on the Select option as shown below:

How to unzip files in Linux

Step5. Now we move to the selected folder or directory to verify that file is unzipped.

How to unzip files in Linux
Next Topicchroot Command





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA