How to use unzip command in Linux

66
linux

ZIP is one of the most common methods for creating a compressed archive file that was created in 1989. Since Linux unzip is used widely in the world today, you can see it everywhere on the internet. In this article, I will show you how to use the unzip command in Linux.

Install unzip linux

Firstly, make sure the unzip package is already installed on your system. You can use the ‘which unzip‘ command to check. The most modern Linux distributions come with unzip support, but there is no harm in verifying it by reinstalling unzip.

Use this command to install unzip on Ubuntu or Debian based distributions.

sudo apt install unzip

Once you have done the above command, let’s start to unzip a zip file in Linux.

How to unzip file on Linux

There are two ways to unzip a zip file on Linux: unzip file via command line or unzip file via GUI.

Unzip file via command line

Using the unzip command on the terminal is the easiest way and it’s very simple. In the directory containing the zip file, use this command:

unzip zipped_file.zip

Or

There is a problem when you extract a zip file from the current directory. That’s not a pretty thing, because you may move those files to another directory after extracting them.

This command will show you how to extract a zip file to a specific directory. If the destination directory does not exist, it will create a new one. By using this command:

unzip zipped_file.zip -d unzipped_directory

With the above command, all files are inside the zipped_file. The zip file will be extracted to the unzipped_directory directory.

In case you want to see which file inside zip file, you can use this command to check with -l option.

unzip -l zipped_file.zip

When you execute the above command, you will get an output like this:

unzip -l metallic-container.zip 
Archive:  metallic-container.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
  6466010  2021-05-07 10:10   file-temp.jpg
     2362  2021-05-07 13:29   temp.txt
---------                     -------
  6468372                     2 files

There are many options for the unzip command in Linux. But I think the above commands are enough knowledge to extract a zip file.

Unzip file via GUI

If you have just started using Linux and are not familiar with using the terminal, there is a solution for you to unzip a zip file on Linux using the Graphic User Interface. I am using GNOME Desktop on Ubuntu 20.04 and the process is pretty much the same as on other Linux distributions.

Firstly, open the file manager and go to the directory where you are storing the zip file. Click the right mouse on the zip file and you will see the option “extract here“. And select that option.

blank

Unlike the unzip command which I have shown you above, the “extract here” option via GUI will create a new folder with the same name as the zip file and the content of the zipped file will be extracted to the newly created folder.

If you want to extract all the content of a zipped folder to a specific folder, follow these steps. There is an “extract to” option for you to do that.

Conclusion

In this guide, I have shown you two ways to unzip a zipped file in Linux using the command line and a graphic user interface. If you have any questions about the unzip command, don’t be afraid to contact us to get more information!

Previous articleHow to use bash sleep command in Linux?