1. Home
  2. Linux

How to use unzip command in Linux

The unzip command is incredibly useful on Linux. With it, you can quickly extract many ZIP archive files without any effort at all. 

In this guide, we’ll show you how to use the unzip command on Linux. To get started, create a ZIP archive on your Linux system and follow along below!

Installing the Unzip tool on Linux

The Unzip tool does not come pre-installed on every Linux operating system out there. On some Linux operating systems, users will need to manually install the app before attempting to use the Unzip command. 

Install Unzip on Linux

Before we go over how to use Unzip, we must demonstrate how to install it. To start installing the app on your Linux PC, you must have a terminal window open. To open up a terminal window, press the Ctrl + Alt + T keyboard combination or search for “Terminal” in the app menu.

Once a terminal window is open and ready to use on your system, follow the command-line installation instructions down below to get Unzip working on your Linux PC. 

Ubuntu

On Ubuntu Linux, the Unzip tool can easily be installed using the Apt command below in a terminal window.

sudo apt install unzip

Debian

If you’re on the Debian Linux operating system, you will be able to install the Unzip app using the Apt-get command below.

sudo apt-get install unzip

Arch Linux 

On Arch Linux, you will be able to get the Unzip app set up by making use of the following Pacman command in a terminal window.

sudo pacman -S unzip

Fedora

On Fedora Linux, it is possible to get the latest release of Unzip installed by making use of the following Dnf installation command.

sudo dnf install unzip

OpenSUSE

If you’re an OpenSUSE Linux user, you will be able to get the Unzip application up and running by making use of the following Zypper installation command in a terminal window.

sudo zypper install unzip

Unzip command in Linux – Unzipping a single Zip archive 

Unzipping a single Zip archive is what most people need to do with the unzip command. Here’s how to do it. First, locate the location of your Zip archive on your computer.

In this example, the Zip archive is in the home directory (~), which is the folder that the terminal session starts at when opened.

First, execute the ls command to view the contents of the home directory. 

ls

Look through the ls prompt for the filename of the Zip archive. In this example, the Zip file is known as “test.zip.”

After learning the name of the Zip archive, it is time to extract its contents. Using the unzip command, extract the “test.zip” file.

unzip test.zip

When the command finishes, you should see the Zip archive contents in the directory in which it was extracted.

Unzip command in Linux -Unzipping multiple Zip archives at once

Along with unzipping single files, it is possible to unzip multiple files using the Unzip command in Linux. To unzip multiple files at once, do the following.

First, use the terminal to access the exact location of the files in which your ZIP archives reside in the filesystem. In this example, we will be working with ZIP files in the “Downloads” directory.

cd /home/USERNAME/Downloads/

Once inside of the “Downloads directory, the extraction can begin. Using the command below, extract every single ZIP archive at once using Unzip. 

unzip '*.zip'

When the unzipping process is complete, all Zip archives’ contents in the “Downloads” directory will be extracted.

Unzip command in Linux – Listing contents inside of a Zip archive

One of the most useful features of the unzip command is the “l” feature. It allows users to examine a compressed Zip archive and view its contents without having to extract it. Here’s how to use it.

First, open up a terminal window and move into the exact location in which your Zip archive is located. In this example, we will be examining a Zip file in the “Documents” directory.

To access the Zip archive in the “Documents” directory, I would use the CD command to access the Documents folder.

cd /home/USERNAME/Documents

Once inside the “Documents” folder, I can execute the unzip -l command to view the Zip archive’s contents.

unzip -l MY_ZIP_ARCHIVE.zip

After executing the unzip -l command, Unzip will print out a list of files inside of your Zip archive that you can look over.

More information

The Unzip command has a lot of features and options that we haven’t covered in this guide. If you want to learn more about the Unzip command on Linux, we highly recommend checking out the Unzip manual. To access it, execute the following terminal command.

man unzip

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.