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.
Table of Contents
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.
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
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:
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:
Now click on the files you want to extract to highlight them and click on Extract:
Choose where you want to extract the file and click on Extract:
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.
What command can be used to install missing tools on Fedora 29?
What command can be used to install missing components on CentOS 7?
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?
Which command can be used to create a ZIP file and include a subdirectory?
With which command should we archive the working directory and all its subdirectories?