How to Zip Files in Ubuntu 22.04


For someone who doesn’t know anything about the ins and outs of an operating system, even the simplest tasks can look like monumental undertakings. Zip files are amazing at preserving your files while reducing your hard disk drive consumption. There is a variety of applications that can help on Windows, but on Ubuntu, the process is fairly straightforward.

On Ubuntu 22.04, if you know what you’re doing, creating and handling zip files in Ubuntu can be a breeze. I’ll first show you how to create zip files through the File Manager and then through the terminal. If you follow through with this tutorial, you’ll be handling your zip files like a pro.

Optional: Installing Zip

Though many Linux distros come with Zip installed out of the box, we can check if it’s there or not by using:

$zip

If you see an output similar to the one above, it means that you zip already installed on your Ubuntu 22.04, and you can skip installing it.

If it’s not already installed in your Ubuntu, you can go ahead and install Zip by running:

$sudo apt install zip -y

Once the Zip installation completes, we are ready to start playing around with Zip files.

Zipping through the File Manager

After Zip has been successfully installed on your Ubuntu 22.04, open up your file manager and navigate to the directory where you want to create the zip file. Select each file you want to add to your zip archive.

Now, you need to right click on any selected file and select “Compress”.

In the next window, you can select a name for the zip file and change the format of the file to anything like zip, protected zip, tar.xz, and 7z. Type the name, select your desired format and press the buttone titled “create” located in the upper right corner of the dialog box.

This will create a new zip file, containing your selected files, in the current working directory.

Now if you want to unzip this archive, you can either unzip it in the same directory with “extract here” or you can use “extract to” to specify a directory other than the current one.

This is all there is to zipping and unzipping files in Ubuntu through the File Manager.

Zipping files through the terminal

To zip a file through the terminal is pretty straightforward. You need to understand the usage of the command. So, let’s take the example of the same stock images. Say we want to create a zip archive with the 5 stock images that we have.

The format for zipping command is:

$zip [name of the zip archive] [names of the files (with spaces) to add to the archive]

We can use the following:

$zip stockimages.zip 1.jpeg 2.jpg 3.jpg 4.jpg 5.jpeg

Once this completes you will see the zip file created in your directory.

Unzipping is simple. You can run this to extract the files in the same directory:

$unzip stockimages.zip

Zipping folders through the terminal

Unlike the files, you can zip folders using the zip command in the terminal, but it’s a bit trickier. Let’s say you have a folder containing these stock images. If you execute the following:

$zip stockimages.zip stock_images

You will create an archive but without any content in it. So, you have to take a recursive approach so that the command will go through all the files within the folder and add them to the archive. Now what you need to execute is:

$zip -r stockimages.zip stock_images

Unzipping is similar to files, you can run:

$unzip stockimages.zip

If you already have the source files in the same directory, you will be prompted if you want to replace them all, update them or do nothing.

Conclusion

Compared to Windows, I like the way Ubuntu gives more control over the whole process of zipping and unzipping files. If you’ve managed to stick with the guide through to the end, you now know everything there is about Zip files on Ubuntu.

Like always, feel free to drop a comment in the thread below to start a conversation if there are any issues at any step of the process.

Print Friendly, PDF & Email
Categories