Ubuntu

How to ZIP a Folder in Ubuntu 22.04

ZIP is an archive file format that helps you to organize your files by making them compressed in a single folder or directory. The benefit of zipping a folder is that it contains all those files which are necessary but required after some time. We zip those files by compressing them and storing them in a computer that occupies less space and can be unzipped later when needed.

In this blog, different methods have been explored by which we can zip a folder in Ubuntu 22.04.

How to ZIP a Folder in Ubuntu 22.04?

There are two different methods to ZIP a folder in Ubuntu:

Method 1: How to ZIP a folder in Ubuntu 22.04 using the terminal

To zip a folder in Ubuntu, first install the ZIP utility in Ubuntu by executing the below-mentioned command:

$ sudo apt install zip -y

To confirm the successful execution of the above command, check the installed version of ZIP utility:

$ zip --version

In the above screenshot, the “Zip 3.0” is confirming that the utility of ZIP has installed.

What is the utilization of the ZIP utility in zip a folder?
The general syntax of using the ZIP utility to ZIP a folder is:

$ zip [options] [folder name with .zip extension] [Folder name which is to be zipped]

Following the above syntax:

  • use the zip utility.
  • Then, choose the zip utility options according to your requirement.
  • A new name for the zipped folder with zip extension.
  • Lastly, the folder name is going to be zipped.

Example
Suppose we have a directory with the name “LinuxHintFiles1” in our home directory and we want to compress it:

$ ls

And this folder contains a couple of files in it as well:

$ ls LinuxHintFiles1

In the above output, it can be seen that the folder, “LinuxHintFiles1” contains seven different files.

To zip the “LinuxHintFiles1” folder using the ZIP utility, use the below-mentioned command:

$ zip -r myZippedFolder.zip LinuxHintFiles1

In the above command, the option “-r” of the ZIP utility has been used to move the folder into the zip file format.

To confirm the compression of the folder using the ZIP utility, again list down the contents of the directory:

$ ls

In the above figure, the red color of the folder shows that it has been zipped. There are many other options that can be used with the ZIP utility and can be found by running the command:

$ zip --help

Different options with their specific usage have been displayed on the screen.

Method 2: How to ZIP a Folder in Ubuntu 22.04 using a GUI method

To ZIP a folder through the GUI interface, right-click on the folder which is supposed to be archived:

Choose the “Compress…” option from the drop-down menu:

Type the name for the zipped folder and click on the “Create” button on the top of screen:

The Zipped folder has been created:

It can be verified that the zip folder has been created.

Conclusion

A Zip utility can be used to zip a folder using the command ”zip -r [name.zip] [folder name]” in Ubuntu 22.04 to change its format to archived. In this blog, the folder has been zipped by two different approaches, one is by using the GUI approach, and the other one is through the command-line interface.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.