Beginner

How to extract the file on Linux [Command line]

Tutorial Unzip A Zip File In Linux With 7 Different Methods
1
(1)

As you know, the most popular and widely used compression formats today are zip, tar.gz, and rar. Zip is an archive file format that contains one or more compressed directories. It supports lossless data compression. Today we are with you with the tutorial on How to Unzip A Zip File In Linux With 7 Different Methods.  If you want to buy a Linux VPS server, you can visit the services available in Eldernode.

How to Unzip A Zip File In Linux With 7 Different Methods

Compression and extraction are one of the most important tasks used in any operating system. If you have used Windows for this, you will notice the ease of work, but in Linux, it is a little different. For example, if you want to extract a compressed file, you can graphically enter the folder or right-click and extract. But there are times when you have no graphical access at all. So you should be able to extract the file or compress the file through the terminal and command.

Recommended Article: Tutorial How To Partition CentOS 8 With SSD and NVMe Storage

Unzip a Zip File in Linux using Linux Terminal

First, install the Unzip package with the following command:

On Ubuntu/Debian:

sudo apt install unzip

On CentOS/Fedora:

sudo yum install unzip

Note that some Linux distributions have the unzip package by default and you don’t need to install it.

In this step, you need to navigate to the ZIP file. To do this enter the following command:

cd directory

Now it’s time to unzip a zip file. If you want to unzip the zip file to the current directory run the command below:

unzip your-file.zip

But if you want to unzip the zip file to a different directory, just use the following command:

unzip your-file.zip -d directory

 

How to compress and extract a ZIP file in Linux

 

Unzip a Zip File in Linux using Python

You can unzip a zip file using Python scripting language which contains all the necessary modules.  To do this enter the following command:

#!/usr/bin/env python3  import sys  from zipfile import PyZipFile  for zip_file in sys.argv[1:]:      pzf = PyZipFile(zip_file)      pzf.extractall()

Now enter the command below to unzip the zip file:

./pyunzip.py master.zip

Or

python3 pyunzip.py master.zip

Unzip a Zip File in Linux using Perl

Perl scripting language can unzip the zip file on Linux. First, enter the following script:

#!/usr/bin/env perl  use Archive::Extract;  foreach my $filepath (@ARGV){      my $archive = Archive::Extract->new( archive => $filepath );      $archive->extract;  }

Run the command below to unzip the zip file:

./perlunzip master.zip

Or

perl perlunzip.pl master.zip

Unzip a Zip File in Linux using Bzip2

You can unzip the zip file in Linux easily with Bzip2 using the following command:

bzip2 -kvd testfile1.txt.bz2 testfile2.txt.bz2

To get Bzip2 options, enter the command below:

bzip2 -help

Unzip a Zip File in Linux using Tar

All you have to do is enter the following command:

tar -xzvf Documents.tgz Documents

The xzvf options break down as x  for extract, z for unzipping with gzip, v for verbose, and f for file means to keep the file structure.

You can view the tar options with the following command:

tar -help

Unzip a Zip File in Linux using Linux GUI

In the first step, you should find the zipped archive and right-click on it. Choose Extract Here from the among options. If you want to put the contents somewhere else, you can choose Extract to:

 

Unzip-zip-file-Linux-GUI

 

The files will be extracted.

Unzip a Zip File using Archive Manager in the Linux GUI

Some Linux distributions have an archive manager to unzip a zip file.

Right-click on the zipped file and choose Open With Archive Manager:

 

Unzip-open-with-archive-manager

 

Now click on the files you want to extract to highlight them and click on Extract:

 

Unzip-highlight-files

 

Choose where you want to extract the file and click on Extract:

 

Location-of-zipfiles

 

That’s it!

Conclusion

Unzipping files is one of the most important tasks used in any operating system, especially the Linux operating system. In this tutorial, we tried to learn you how to compress and extract zip, tar, tar.gz files, and extract RAR files.  In this article, we taught you How to Unzip A Zip File In Linux With 7 Different Methods. If you have any questions or suggestions, you can contact us in the Comments section. I hope this tutorial was useful for you.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

5 thoughts on “How to extract the file on Linux [Command line]

  1. Which command is used to create a file called source_code.zip that contains all the source code C files and header files in the current directory?

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day