How to unzip a zip file on Ubuntu?

Here, you will learn how to unzip a zip file on Ubuntu and zip them again if required.

Updated: 05 Mar, 23 by Susith Nonis 4 Min

List of content you will read in this article:

In this article, we want to talk about how to zip and unzip files using the terminal and the GUI method on Ubuntu. Keep along with us!

  • Open up your terminal window by pressing Ctrl + Alt + T or going to the command box at the left above the top of your screen and clicking on the “open in PuTTY” option.
  • Once you have done that, you will be greeted with your user name, which you have entered into WinSCP to connect originally.
  • Now you will need to put in your password. If you forget your password, you can easily find that by returning to your server details.
  • Copy your password and go back to the terminal window.
  • Right-click to paste the password and then hit Enter.
  • Now, you will be logged in to your server via SSH.
  • By default, the unzip command is installed on your system, but if it is not, then you can install it by the command below:

$ sudo apt install unzip

  • Once you have typed that in, hit, Enter and your server will begin installing “unzip”. 
  • Once that has been installed, you are now ready to unzip your file by entering the following command:

unzip [FileName].zip

  • Once you have entered the command and replaced “file name” with the name of your zip file, you can hit Enter, and your server will begin unzipping that.
  • Now, check out if it has been completed or not.
  • To do so, you will refresh your service directory and see all the files you have unzipped.
  • Now. You can change the directory and move the unzipped files by using the following command:

cd [Directory-Name]

To unzip a file in a different directory, you should use the following syntax:

unzip [FileName].zip -d /[Directory-Path]

A zip file includes a set of files and their descriptions. When you unzip such a file, you will see all the information about each containment. To avoid this, you can use the “-q” flag in the above syntax:

unzip -q [FileName].zip

You can also extract only the files you need during the unzipping process and exclude the rest. To do this, you can use the “-x” flag in the above syntax while considering spaces between the file names:

unzip [FileName].zip -x “*Filename1*” “*Filename2*”

To avoid overwriting files that are already extracted, you should use “-n” flag in the command line:

unzip -n [FileName].zip

To unzip multiple files in a directory, you should use the following command:

unzip ‘*.zip’

Type the following command to check the number of zip files in a single directory:

ls [directory_name]

To unzip a file on the Ubuntu system, you do not always have to go to the terminal. If you are using the GNOME desktop, you can do this process through the graphical user interface (GUI) by following these steps:

  • Open the file manager.
  • Go to the folder where your zip file is stored.
  • Right-click on the file.
  • Select the “extract here” option.
  • You can also see an “extract to” option, which helps specify the folder where you want to extract the files.

To zip multiple files on an Ubuntu server, you should compile all the files into a single folder that you to zip. Then, you should follow these steps:

  • Open up your SSH terminal.
  • Install “zip” by typing the following command:

apt install zip

  • Hit Enter.
  • Now, “zip” will begin installing onto your server.
  • Once that is done, you are ready to enter the zip command:

zip –r  zip [FileName].zip the [FolderName]

  • By zip File Name, we mean the name of the new file you are generating.
  • By Folder Name, we mean the folder that you want to zip.
  • Once you type the above command, hit Enter.
  • Now, your server will begin zipping the file you entered in the command.

Here, you learned how to unzip a zip file on Ubuntu and zip them again if required. Do not hesitate to ask us if you have questions about this article or everything related to the Linux system. Good luck!

People also read: 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.