How to Zip Files and Folders in Linux [Beginner Tip] – It’s FOSS

Brief: This quick tip shows you how to create a zip folder on Ubuntu and other Linux distributions. Terminal and GUI methods have been discussed.

Zip is one of the most popular file formats out there. With zip, you can compress multiple files into a single file. This not only saves disk space, but also saves network bandwidth. That’s why you’ll find zip files almost all the time.

As a normal user, you will mostly unzip files on Linux. But how do you compress a folder on Linux? This article helps you answer that question.

Prerequisite: Check if

zip is installed

Normally zip support is installed, but there is no harm in verification. Open a terminal and use the following command:

zip -version If you

see some details about the zip version, you already have zip installed. If it shows ‘zip command not found’, you can run the following command to install zip support and unzip on Ubuntu and Debian based distributions.

sudo apt install zip unzip

Now that you know your system has zip support, you can read on to learn how to compress a directory on

Linux.

Compress a folder on the Linux command line

The syntax for using the zip command is pretty straightforward.zip

[option] output_file_name entry1 entry2

While there could be several options, I don’t want you to be confused by them. If your only goal is to create a zip folder from a bunch of files and directories, use the command like this: zip

-r output_file.zip file1 folder1

The -r option will repeat in directories and compress its contents as well. The .zip extension in output files is optional as it is .zip added by default.

You should see the files that are added to the compressed folder during the zip operation.

zip -r myzip abhi-1.txt abhi-2.txt sample_directory Adding: abhi-1.txt (stored 0%) Adding: abhi-2.txt (stored 0%) Adding: sample_directory/ (stored 0%) Adding: sample_directory/newfile.txt (stored 0%) Adding: sample_directory/agatha.txt (deflated 41%)

You can use the -e option to create a password-protected zip folder on Linux

.

It is not always restricted to the terminal to create compressed files. You can also do it graphically. Here’s how!

Compress a folder in Ubuntu Linux using GUI

Although I have used Ubuntu here, the method should be more or less the same in other distributions that use GNOME or another desktop environment

. If you want to compress a

file or folder on desktop Linux, it’s just a matter of a few clicks

.

Go to the folder where you have the desired files (and folders) that you want to compress into a zip folder.

Here, select the files and folders. Now, right-click and select Compress. You can also do the same for a single file.

You can now create a compressed archive in zip, tar xz or 7z format. In case you’re wondering, these three are various compression algorithms that you can use to compress your files.

Give it the name you want and click Create.

It shouldn’t take much time and you should see an archive file in the same directory.

Well, that’s it. You have successfully created a zip folder on Linux. The next step is to learn how to unzip a compressed file on the Linux command line.

I hope this little quick tip helped you with zip files. Please feel free to share your suggestions.