How to Zip Files and Folders on Ubuntu

This guide will show you how easy it is to zip files and folders on an Ubuntu system.

Ubuntu Zip Files and Folders

Zip is one of the most used archive formats in the world. An archive is used to store multiple files and folders within a single file.

In the case of zip, it can also losslessly compress the files stored within its archive. This compression helps reduce the amount of space the files consume on your Ubuntu system.

We will need to install some additional packages to zip files and folders on an Ubuntu system using the command line.

The desktop version of Ubuntu includes a utility we can use to archive files and filers using the Zip format.

You can also use Ubuntu to unzip these files using a single command or the handy desktop interface.

Table of Contents

Zip Files and Folders on Ubuntu using the Command Line

Using Zip to archive your files and folders on Ubuntu is a relatively straightforward process.

All of this is possible by using a package called “zip“.

For the following steps, you will need to use the terminal. You can open the terminal on Ubuntu desktop by pressing CTRL + ALT + T.

These steps will also work if you manage your system using an SSH connection to your Ubuntu machine.

Installing the Zip Package

Before we can zip files and folders on Ubuntu, we need to install the zip package.

The zip package is the tool that we can use to archive folders and files in the zip format.

1. Our first step is to update Ubuntu’s package list and the packages themselves.

Updating the package list ensures that you will be downloading the latest available version of the zip package.

We upgrade the rest of the packages to ensure we won’t have any issues caused by out-of-date packages.

sudo apt update
sudo apt upgrade

2. We can now install the zip package to Ubuntu by using the apt package manager.

Run the following command on your system to install the zip command-line tool.

sudo apt install zip

The Syntax for the Zip Command

Using the zip command on Ubuntu is an incredibly simple process.

The command’s syntax is straightforward to remember and super easy to understand.


The main two things you must include are the output filename (OUTPUT_NAME) and the files or folders you want to archive (INPUT_FILE_FOLDER).

You can include as many files or folders as you want to store into the zip archive. Each input file needs to be separated by a space.

It is also possible to feed options into the zip command to control how it works on Ubuntu. The following few sections will explore a couple of the simple options that you can use.

Using Zip to Archive Individual Files

The first thing you will learn is how to zip individual files on Ubuntu.

This method is one of the simplest ways of using zip but is useful when you don’t want to archive entire directories.

Below is the most basic version of this syntax.


Example of Zipping a Single File

For this example, let us say that we wanted to archive a single file called “exampleTextFile.txt” to an archive called ““.

zip exampleTextFile.txt

From this, you should end up getting a message as we have below.

This output tells you the file added to the zip archive and the amount that it has been compressed.

  adding: exampleTextFile.txt (deflated 62%)

Example of Zipping Multiple Files

You can also use zip multiple files using this command on Ubuntu.

For this example, we will be using zip to archive three files, one called “exampleTestFile.txt“, another called “exampleimage.png” and lastly, one called “pimylifeup.txt“.

We will zip these files on Ubuntu to a file called ““.

zip exampleTextFile.txt exampleimage.png pimylifeup.txt

As you can see, using zip to archive multiple files on Ubuntu is a straightforward process. All you need to do is reference the name of each of your files.

Below is an example of what you will see after running the zip command on your machine.

updating: exampleTextFile.txt (deflated 62%)
updating: exampleimage.png (deflated 0%)
  adding: pimylifeup.txt (deflated 18%)

Zip All Files in a Folder

The zip package on Ubuntu also has the ability to archive all of the files within a folder.

We can do this by using the wildcard symbol (*) to select all of the files within the directory.

For example, to zip all files within the current directory on Ubuntu, we can use the following command.

zip *

From this command, you will see every file and folder listed as being archived into the current directory.

  adding: Bookshelf/ (stored 0%)
  adding: Desktop/ (stored 0%)
  adding: Documents/ (stored 0%)
  adding: Downloads/ (stored 0%)
  adding: exampleimage.png (deflated 0%)
  adding: exampleTextFile.txt (deflated 62%)
  adding: Music/ (stored 0%)
  adding: Pictures/ (stored 0%)
  adding: pimylifeup.txt (deflated 18%)
  adding: Public/ (stored 0%)
  adding: Templates/ (stored 0%)
  adding: Videos/ (stored 0%)

While using the zip command like this will archive the folders themselves, it won’t archive their contents.

Our next section will show you how to zip the contents of folders on Ubuntu,

Zip a Folder on Ubuntu

We can also use the zip package on Ubuntu to archive all of a directory’s contents, including its subdirectories.

This follows a very similar syntax to zipping individual files. We just have to make use of the recursive option (-r).


Example of Zipping Folders

For this example, we will use zip on Ubuntu to archive the contents of a folder called “Documents“. This folder contains another folder named “example“.

You will see how by adding the recursive tag, the contents of both of these folders will be stored by zip the package within a archive.

zip -r Documents/

From this command, you can see that the recursive function loops through the Documents folder, adding its contents.

It will then loop through every sub-directory, placing each file into the zip archive.

adding: Documents/ (stored 0%)
adding: Documents/exampleTextFile.txt (deflated 62%)
adding: Documents/exampleimage.png (deflated 0%)
adding: Documents/example/ (stored 0%)
adding: Documents/example/hellofile (stored 0%)
adding: Documents/example/testfile (deflated 16%)

The zip package does not feature a max-depth feature. So it will continue to archive files till it gets to the very last folder.

Using Ubuntu Desktop to Zip Files and Folders

Using the Ubuntu desktop interface to compress files and folders into a zip archive is very simple.

The desktop versions of Ubuntu comes, with support for compressing files and folders into the zip archive format, so we don’t need to install any additional software.

We took the following screenshots on Ubuntu 18.04. These same steps should work the same for newer releases such as Ubuntu 20.04.

If you are unsure, we have a guide that shows you how to tell what version of Ubuntu you are running.

1. On Ubuntu desktop, find the files that you want to compress and select them.

To show how this works, we will be compressing some sample files that we created.

Select Files to Archive

2. Once you have the files and folders you want compressed selected, right-click one of them.

This will bring up a menu. Within this menu, find the “Compres... option and click it.

Choose Compress Option in Right-Click Menu

3. First, you will need to give the archive a name (1.).

Once you have set a name, make sure that the “.zip” option is selected (2.).

Finally, we can get Ubuntu to create the zip archive by clicking the “Create” button (3.).

Create ZIP Archive on Ubuntu

4. At this point, you should now have your freshly compressed zip archive.

It will utilize the name that you defined as its filename.

Zip Created on Ubuntu


Hopefully, by now, you will know how you can compress files and folders into a zip archive by using the zip command.

Compressing files using this format is a straightforward process whether you are using the desktop interface or command line.

If you have had any issues with creating a zip archive on your Ubuntu system, please leave a comment below.

Be sure to check out some of our other Ubuntu guides to learn what else you can do with your system.

Leave a Reply

Your email address will not be published. Required fields are marked *