Jannah Theme License is not validated, Go to the theme options page to validate the license, You need a single license for each domain name.
Linux

How to Unzip a ZIP File in Ubuntu Linux?

Introduction 

Have you ever wondered how individuals and organizations can handle and transfer large files with relative ease? The answer to this lies in the utilization of a zip file. Essentially, a zip file acts like an envelope that can accommodate your numerous unorganized documents. The envelope is also automatically compressed, making it fit perfectly into any storage space. This compression process considerably reduces the file size, making sharing easier across various networks.

Did you know that a compressed file is a type of archive file format? It is compressed using compression algorithms and offers many benefits, such as data security, easy sharing, and lower storage space requirements.

This article will guide you through the steps of installing the zip and unzip utility. Additionally, a specific section includes measures to Unzip a ZIP File in Ubuntu Linux. Let’s begin.

How to Install the Zip and Unzip Utility in Ubuntu? 

Before downloading the utility, we highly recommend taking a brief moment to familiarize yourself with its functionalities. This particular command-line tool can both compress and decompress files and directories with ease and can efficiently manage multiple files simultaneously. With this small piece of understanding about zip and unzip utility, we will move towards the steps of the downloading process. After this process, we will learn to Unzip a ZIP File in Ubuntu Linux.

  • Start the terminal window by pressing Ctrl+Alt+T.
  • Before you download the utility, make sure you have an updated package. To do so, simply enter the below command.
sudo apt update
Install the Zip and Unzip Utility in Ubuntu
  • After the package is updated, enter the below command to install the utility. 
sudo apt install zip
Install the Zip and Unzip Utility in Ubuntu
  • Once you have installed the utility, simply enter the user account password and press enter.
  • Your zip utility is installed now; we will install the unzip utility using the code below.
sudo apt install unzip
Install the Zip and Unzip Utility in Ubuntu
  • Again enter the user account password and press enter. 
  • The installation is complete, and you just have to verify the installation by creating a zip file.
  • Use the below code to create and unzip a .zip file in Linux.

# Create a new ZIP file with a test.txt file inside

zip test.zip test.txt
Create a new ZIP file with a test.txt file inside
Create a new ZIP file with a test.txt file inside

# Unzip the test.zip file

unzip test.zip
Unzip the test.zip file

Once you have successfully executed the unzip commands in Linux, you can confirm that the process has been completed.

Unzip a File Using the Command Line 

The process of unzipping a .zip file in Linux is as easy as zipping it. Follow these steps to learn the unzipping process quickly. 

  • Press Ctrl+Alt+T to open the terminal window.
  • Now you need the correct path of the zip file to proceed further. Use the below command to navigate the zip file in the terminal window.
cd ~/Downloads
Unzip a File Using the Command Line 
  • Replace the’`/downloads’ with the correct path of your zip file.
  • Once the navigation is done properly, simply enter the below command to unzip a .zip file in Linux.
unzip example.zip
Unzip a File Using the Command Line 
  • The final step is verifying the unzipping process by personally visiting the directory where the extraction process occurred.

Also Read: Steps to Unzip/Extract tar.gz Files in Linux Using Command Line

Other Linux Unzip Commands 

1. How to Unzip Multiple ZIP Files?   

The above utility, which we have just downloaded through a terminal window, is capable enough to unzip multiple files. All you have to do is open the terminal window through Ctrl+Alt+T and navigate the zip files through the command ‘cd ~/Downloads.’ Make sure to replace the ‘~/downloads’ with the actual path of your zip files. Now you just have to invoke the terminal window loop through the code below.

for zip_file in *.zip; do unzip "$zip_file"; done

This command will start a process where all the zip files of the current directory will be unzipped swiftly.

2. How to Test if a ZIP File is Valid 

To test if a ZIP file is valid and not corrupted, you can use the “unzip” command with the “-t” option. This option allows you to test the integrity of the ZIP file without actually extracting its contents. Here’s how you can do it:

  1. Open a terminal window in Linux.
  2. Navigate to the directory where the ZIP file is located using the “cd” command. For example, if the ZIP file is in the “Downloads” folder, use the following command:

The “unzip” command will check the ZIP file’s integrity and display the result. If the ZIP file is valid and not corrupted, it will show a message indicating that the test was successful. On the other hand, if the ZIP file is corrupt or invalid, it will show an error message indicating the issue.

Also Read: How to Change File Permissions Recursively With Chmod in Linux?

Conclusion

In this guide, we will explore the process of installing the zip and unzip utility in Ubuntu Linux, as well as how to utilize the command line to unzip a .zip file. The zip utility is a tool for compressing files and directories, while the unzip utility extracts contents from zip files. Linux users often find unzipping files to be a useful way of managing large amounts of data and easily sharing information across networks. With the zip and unzip utilities, managing archives and extracting their contents becomes a straightforward and effortless task.

Arpit Saini

He is the Director of Cloud Operations at Serverwala and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.

Related Articles