How to Unzip Files in Linux

0

Archive(zip) files reduce space consumption to make the data transferable. That’s why most files you download from the web are in zip formats like tar, zip, and rar. However, you first need to unzip these files to access the data. 

Although a few tools are available to unzip files, Linux contains simple commands that can be used to unzip files quickly. Therefore, in this quick tutorial, we will explain different ways to unzip files in Linux. In this section, we have included commands and graphical tools to unzip files without getting errors.

From File Manager

 If you are new to Linux, we recommend that you use the File Manager to unzip the files. First, open the File Manager and go to the directory where you saved the zip file. 

downloads-directory-in-file-manager

Now, right-click on the file; you will get two “extract here” and “extract to” options. So please choose “extract here” to unzip the file in the same directory or “extract to” to unzip the file in any other directory. 

drop-down-menu-in-file-manager-to-extract-filedrop-down-menu-in-file-manager-to-extract-file

In case the zip file is password protected, the system will give you a pop-up window to enter the password:

unzip-the-password-protected-file-in-linuxunzip-the-password-protected-file-in-linux

The unzip Command

If you’re specifically dealing with a zip format file, use the unzip command. Otherwise, you can jump right into the next section. To unzip a file using the unzip command, first navigate to the directory where the zip file is located. For example, let’s open the Downloads directory:

open-downloads-directory-using-cd-commandopen-downloads-directory-using-cd-command

Now use the unzip command in the following manner:

unzip-the-directory-using-the-unzip-commandunzip-the-directory-using-the-unzip-command

If you want to list the content of a zip file, then please use the -l option:

the-l-option-unzip-commandthe-l-option-unzip-command

You can also extract the zip file data in any other directory by using the -d option: 

unzip Script.zip -d ~/Documents

the-d-option-in-unzip-commandthe-d-option-in-unzip-command

In case the zip file is password protected, you need to use the -P option, including the password in the command: 

unzip -P 12345 Scripts.zip

the-p-option-in-unzip-commandthe-p-option-in-unzip-command

The tar Command

The tar is the second most commonly used archive format after ‘zip’, which makes it equally essential to be aware of. For unzipping ‘tar’ files, Linux provides the tar command that can handle formats like ‘.tar,’ ‘.tgz,’ ‘.taz,’ ‘.tar.xz’, and more. Let’s take an example of a zip file, ‘Scripts.tar,’ and unzip it using the tar command:

the-xvf-option-tar-commandthe-xvf-option-tar-command

Furthermore, if the tar archive is compressed using gzip and bzip2, use the ‘-z’ or ‘-j’ options, respectively. For instance, had the file in the above example been ‘Scripts.tar.gz’ or ‘Scripts.tar.bz2’, we would have used:

tar -xvfz Scripts.tar.gz  OR  tar -xvfj Scripts.tar.bz2

xvfz-option-in-tar-commandxvfz-option-in-tar-command

A Quick Wrap-up

Unzipping a file is a fundamental task, and as a Linux user, you must know the various methods to unzip a file. This short guide explains the two common commands that let you unzip files of different archive formats. For the zip format, the straightforward approach is via the unzip command, whereas for other formats, you must use the tar command.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More