How to unzip a zip Archive in Linux (CLI & GUI)
Zip is a type of archival format that is used to compress files and folders. It is widely used because of its good compression rates and support on multiple operating systems.
Here in this short tutorial, I am going to show you how you can unzip (extract) zip files on Linux based operating systems using CLI (Command Line Interface) or GUI (Graphical User Interface).
Unzip zip file in Linux (Using terminal)
Most of the server-oriented Linux installs don’t have a GUI. While it may seem that it would be harder to unzip using CLI (Command Line Interface), in reality it is a very easy and seamless process.
To unzip a zip file, you will need to install a package named unzip. Unzip is already available on the base repositories of many Linux distribution. To install it, simply use this command.
For Ubuntu/Debian based Linux:
sudo apt install unzip
CentOS:
sudo yum install unzip
Arch based distributions (base Arch Linux, Manjaro, etc):
sudo pacman -S unzip
(Note: sudo is only needed if running using user account other than root.)
Next navigate to the folder where you have the zip file (using cd command) and use the following command.
unzip zipfilename.zip
Replace zipfilename.zip with the actual name of the zip file.
If the file name is long and also has spaces between the file name, then you can simply type the starting letters of the file and press tab. This will auto-complete the name of the file and then you can press enter to extract it.
Unizp a password protected zip file
The process is same as the process for the standard zip file. But this time when you click enter, it will ask you for a password. Enter the password and press enter.
Remember that nothing will show on the screen when you type your password, when the prompt for the password appears, type in your passphrase and click enter.
One other way to achieve the same is via using the -P
option. It can be helpful when you want to automate things using scripts or other means but this method is not secure.
You will have to type your password in plaintext and it will be saved in your command history or even in logs in some cases. Be aware of this when passing password using -P
variable.
Here is the syntax:
unzip -P PasswordG0eshere zipfilename.zip
If you want to list the contents of the zip file you can add a -l
flag to your command like this:
unzip -l zipfilename.zip
If you want to extract the contents of the zip file in another directory, use the -d flag.
e.g. unzip -d /path/to/the/directory/zipfilename.zip
Here are some other useful flags for the unzip commands:
-p
: no files gets extracted but are displayed on the terminal
-t
: test the zip archive
-q
: no messages get displayed on the terminal
-T
: change timestamp of the zip file with the latest date/time
Note: The flags are case sensitive.
Unzip in Linux using GUI (Graphical User Interface)
Many GUI options also provide support for creation and extraction of zip files in Linux, here we will be using Ark. I choose Ark because it is available in almost all major desktop and server Linux distribution’s repositories.
To install Ark, simply use these commands or install the package via searching for it in your Distro’s app tore/manager.
CentOS:
sudo yum install ark
Arch Linux:
sudo pacman -S install ark
Debian/Ubuntu:
sudo apt install ark
You can also search for ‘Ark‘ in your Linux Distro’s Package Manager (Known as Software Center in Ubuntu).
When the installation is done, Ark should have been integrated into the right click menu of your Linux distribution.
To extract (unzip) a zip file, simply right-click on it, hover on Extract option and select Extract Archive Here.
Other thing that you can do is open ark (either from app drawer or terminal), Click on Archive and select Open (OR press CTRL+O).
Select the zip archive and all its content should be visible on the Ark app.
You can also drag and drop zip files into the Ark window. You can now see the contents of the zip file and from there you can extract the files to your preferred location.
This does it for this tutorial, if you have any questions, suggestions, regarding this post, feel free to comment down below. If you want to know how to password-protect a zip in Linux, I have also written a tutorial for that.