How to Zip a Folder on Ubuntu 24.04

Zipping a folder on a Linux system, including Ubuntu 24.04 is a useful task that allows users to bundle their files together into a single file. It also helps users minimize their disk space and improves their system’s stability. The reason is that the size of the files will be compressed and reduced when you zip a folder on your system. Once you have done this, you won’t worry about your disk space because you can remove those folders if you have created their zip files.

If you don’t know how to zip a folder on your recently installed Ubuntu 24.04 system, read this blog to find:

How to Zip a Folder on Ubuntu 24.04

You can zip a folder on Ubuntu 24.04 through:

  • Terminal
  • GUI

How to Zip a Folder on Ubuntu 24.04 Through the Terminal

If you want to use the terminal to zip a folder on Ubuntu, you must use the zip command line utility. The zip command line utility is preinstalled on Ubuntu, however, the user can reinstall them from the below-given command in case they have deleted them accidentally.

sudo apt install zip -y
Zip A Folder On Ubuntu 24.04 A

You can confirm the zip installation on Ubuntu by running the following command:

zip --version
Zip A Folder On Ubuntu 24.04 B

Once you ensure the zip command line utility is installed, it’s now time to zip a folder on Ubuntu. There are multiple options you can use with the zip utility to zip a folder. 

The basic syntax to zip a folder on Ubuntu with zip utility is provided below:

zip [zip_filename] [files or folder names added to the zip file]

In the above syntax, replace zip_filename with the name of the desired zip file you want to save on your system. While in the files or folder names added portion, you must add the file or folder name that you want to add to your zip file.

As an example, we are zipping a folder snap on Ubuntu using the following command:

zip snap.zip snap
Zip A Folder On Ubuntu 24.04 C

To add multiple folders, simply add the folder names separated by a space.

Zip A Folder On Ubuntu 24.04 D

If you want to add files instead of folders, you can do it easily by adding the file names with their extensions. Each file’s name should be separated by a space. 

The following example creates a zip file with the name files.zip and adds multiple files named file1.txt, file2.txt, and file3.txt to the zip file.

zip files.zip file1.txt file2.txt file3.txt
Zip A Folder On Ubuntu 24.04 E

You can also add a wildcard symbol * followed by the format of the file to add all files to the zip file simultaneously; the command is provided below:

zip files.zip *.txt

An advantage of zipping a folder with the zip command utility is that you can delete or add a folder or files to a zip file without damaging the zip file. 

To delete a file from the zip file, simply use the -d option with the zip file name followed by the file you want to remove. As an example, the following command will delete a folder Pictures from the folders.zip file.

zip -d folders.zip Pictures
Zip A Folder On Ubuntu 24.04 F

If you want to add a folder or file to a zip file on Ubuntu, you can use the -u argument with the zip filename followed by the folder or file name you want to add. The below-given command will again add a folder named Pictures to the folders.zip file:

zip -u folders.zip Pictures
Zip A Folder On Ubuntu 24.04 G

If you want to encrypt a folder with a password, you can use the -e argument with the zip command. The following command will create a password-protected zip file named folders.zip:

zip -e folders.zip

When you execute the above zip command, it will ask you to enter the password. Do it and verify it again by typing the same password to complete the process of creating a password-protected zip file on Ubuntu:

Zip A Folder On Ubuntu 24.04 H

How to Zip a Folder on Ubuntu 24.04 Through GUI

You can also zip a folder on Ubuntu by using the GUI, it can be done through the following steps:

Step 1: First, navigate to the folder containing the files and folders you want to compress on Ubuntu.

Step 2: Then right-click on the folder and click on the Compress option:

Zip A Folder On Ubuntu 24.04 I

Step 3: Name your zip file according to your choice, once done, click on the Create button:

Zip A Folder On Ubuntu 24.04 J

This will create a zip folder on your Ubuntu system with GUI:

Zip A Folder On Ubuntu 24.04 K

Note: You can select multiple folders simultaneously, right-click from the mouse, and follow the similar procedure you do for creating a zip folder for a single folder.

Bonus Method: How to Unzip a Zip File on Ubuntu 24.04

If you have created a zip folder and want to unzip it, then you will need the unzip command-line utility. Though the unzip utility is preinstalled on Ubuntu, you can use the below-given command to install it again in case you deleted them by mistake:

sudo apt install unzip
Zip A Folder On Ubuntu 24.04 L

Once done, you can unzip a folder on Ubuntu simply by using the unzip command followed by the zip file name, the syntax is provided below:

unzip filename.zip

Here, as an example, we have unzipped a zip file master.zip using the following command:

unzip master.zip
Zip A Folder On Ubuntu 24.04 M

If the zip file is password-protected, then you can unzip it by using the following syntax:

unzip -P write-password filename.zip

To unzip a zip file from the GUI, right-click on the zip file and choose the Extract option to extract the files at the current location. Or, choose the Extract to option to extract the files of a zip file to a different location on Ubuntu:

Zip A Folder On Ubuntu 24.04 N

This is how you can unzip a zip file on your Ubuntu system.

Conclusion

You can zip a folder on Ubuntu 24.04 through the zip utility, which works on both the terminal and GUI. For the terminal, you can use various arguments with the zip command line utility and change the way of zipping a folder on your system. You can even update your zip file without damaging it by adding additional folders or files, which may not work if you use zip through GUI. 

We have discussed both terminal and GUI methods to zip a folder on Ubuntu in the above section of this guide. We have also discussed the method to unzip a zip file using the terminal and GUI to help users extract the files when needed. Following these methods to constantly create multiple zip files or folders can significantly improve your system performance.