2 Easiest Ways to Unzip Files in Linux?

Unzipping is a process to restore the compressed file without any data loss. In Linux distributions, the unzip utility is utilized to serve the purpose. In Linux, the terminal and the GUI (where applicable) of Linux can also be utilized to unzip files. Considering its importance, this guide will demonstrate various methods to unzip files in Linux(Linux-based OS). The content that illustrates this guideline is mentioned below:

Prerequisite: How to Install unzip Package in Linux?

The Linux terminal assists the audience in installing the needed packages from the package manager. To install the unzip package on Debian-based distros, execute the below script:

$ sudo apt install unzip

Now, the unzip package has been successfully installed in Ubuntu (Linux-based OS). To install it on your desired Linux distribution, choose one of the commands written below:

For CentOS:

$ sudo yum install unzip

For Fedora/Redhat:

$ sudo dnf install unzip

For Arch:

$ sudo pacman -S unzip

For OpenSUSE

$ sudo zypper install unzip

How Does the unzip Command Work?

The unzip command works simply to extract the archived file and place all content that is present in the zip file paste in the same directory. The general syntax that follows to unzip the archive file is as follows:

Syntax:

$ unzip zip_file.zip

Using the “help” utility of unzip command, all possible options with descriptions are as follows:

$ unzip -help

How to Use unzip Command in Linux?

In Linux, the “unzip” command extracts all files from the zip archive and pastes them into the same directory. The step-by-step procedure is explained here to access and unzip the specified file:

Example 1: Unzip a File in the Same Directory

An existing zip file, “office.zip”, is carried out after navigating to the specific directory “office”. To display all files and directories in this directory, execute the “ls” command as below:

$ ls

Execute unzip Command

Execute the “unzip” command specifying the name of the zip file as “office.zip”. It extracts all compressed directories and files which is stored in the zip file:

$ unzip office.zip

Users can display a message after successfully executing the above command.

Verify Unzipped Files in the Same Directory

In the office directory, you can verify through the “ls” command that two files, “office1.txt” and “office2.txt”, have been extracted here:

$ ls

Example 2: Unzip a File in Different Directory

Another example is considered using the “-d” option that store to the extracted files in the specified directory as below:

$ unzip Office.zip -d myfolder

The output shows that “a.out”, “file.sh”, “office” files have been successfully in the “myfolder” directory.

Example 3: Unzip Specific Files From Zip File

To unzip a specific file, the “-x” utility is used to extract the specific file and paste it into the same directory. To do so, the syntax is given below:

$ unzip Office.zip file.sh

You can verify that “file.sh” has been extracted in the Home directory utilizing the “ls” command as below:

$ ls

Example 4: Unzip an Encrypted File

Another example is adapted to encrypt the zip file to display all the content that is stored in multiple files. For this, the “-p” utility is used here:

$ unzip -p Office.zip

The output confirms that all content is displayed in the above terminal.

Example 5: Unzip Multiple Files

Users can unzip multiple files by specifying the file type. To unzip different files type, the command is provided below:

$ unzip Office.zip file.sh a.out

The output shows that specified files have been unzipped here.

How to Unzip files in Linux Using GUI?

In Linux, GUI (where applicable) assists in achieving the same task in less time. To unzip files using the GUI in Linux, the step-by-step procedure is provided below:

Example 1: Unzip a File in the Same Directory

An “office.zip” file is considered to perform the unzipping operation. To do so, press the right button of the mouse on the zip file and choose the “Extract here” option from the dropdown list:

After hitting the “Extract Here” option, the “office1.txt” and “office2.txt” have been extracted in the same directory as seen below:

Example 2: Unzip Files to a Specific Directory

You have the option to choose the specific directory to unzip the archive file. For this, select the “Extract to” option by hitting the right button of the mouse on the specified zip file:

It navigates to the new window for selecting the destination. In our case, choose the “CEO” directory and hit the “Select” button located at the top right corner of the window:

Now, users can verify that unzipped files “office1.txt” and “office2.txt” are saved in the “CEO” directory:

Bonus Tip: How to Zip Files in Linux?

A piece of additional information to make a zip file. To do so, there are three existing files in the “Office” directory as seen below through the “ls” command:

$ ls

Two files, “file.sh” and “office”, are considered to make a zip file whose name will be “Boss.zip”. For this, execute the command:

$ zip Boss.zip file.sh office

The “ls” command is utilized to display the zip file “Boss.zip” successfully created here:

$ ls

That’s all from this guide.

Conclusion

In Linux- based OS, the “unzip” command is utilized to unzip files that need to be installed before using it. The “unzip” command requires the name of the zip file for extraction by following the general syntax “unzip filename.zip”. Additionally, a GUI method has also been explained to unzip files into the same as well as specific directories through the “Extract Here” and “Extract to” options, respectively. This guide has provided a brief explanation to unzip files in Linux.