How to zip a folder in Linux

A person typing on a keyboard which has purple backlighting under the keys
(Image credit: Shutterstock)

Knowing how to zipping a folder (directory) in Linux serves various practical purposes, making it a valuable skill for users seeking efficient file management and transfer methods. As with other operating systems like Windows 11 and macOS, compressing files is one of the basics processes you need to know.

One primary advantage lies in compression, as zipping reduces overall size, which means faster file transfers. Compressed folders are a popular choice for creating backups and optimizing storage space while ensuring the portability and accessibility of archived data.

Handling zipped files as a singular entity simplifies organization, sharing, and archiving tasks, streamlining overall file management. In this how-to guide, we'll walk you through how to zip your files in Linux, whether you're accessing files in a Linux distro, like Ubuntu, or using the zip command in the Linux command line interface.

How to zip a directory in Linux

We'll be using the Ubuntu distro in this tutorial. However, these steps should also apply to other distros.

1. Open Files > right click a folder > select Compress

(Image: © Future)

If you're using a Linux distribution (distro) like Ubuntu, then zipping folders is a straightforward process that works in much the same way as zipping folders in Windows.

I'm using Ubuntu, but other distros will have similar functionality. First, open your Files application. Now go to the location of the folder you want to zip and right-click.

Next select Compress from the drop-down window. This opens a new window with a field for Archive name. This will be the name of your zip folder. It defaults to the name of the folder you're compressing, but if you want to use a different name, type that here. Select Create, and your zip folder will appear in your list of folders.

2. Unzip folder in distro Files application

(Image: © Future)

To unzip a compressed folder in your distro Files application, right click the zip folder and select one of the Extract options in the drop-down menu. The Extract Here extracts the contents of the zip folder to your current location. To save the unzipped contents to a different location, select Extract To.

3. Using the zip command

(Image: © Future)

If you want to zip directories using Linux commands, open your command line interface with Ctrl-Alt-T.

The Linux command used for compressing files and directories is zip -r. Enter your command in the format: zip -r <zip file name> <directory name>

In the example above, I have created a zip file for the directory 'Hannah' called

Linux goes through each directory and file in the directory and compresses it. It returns a result every time it has completed an action, so the time it takes to complete the full zipping process, and the length of the list of actions displayed on the screen, will vary depending on the size of your directory.

When the process is completed, you can use the ls command to see your new zip file in the directory.

4. Zip multiple directories

(Image: © Future)

You can combine multiple directories in the same zip file by listing all the directory names in your zip command.

In the example above, I have created a zip file called containing three directories using the command zip -r 'Earl Grey Rooibos Tea' 'Lawn Earl Grey' 'Sainsburys Earl Grey'.

As before, when we created a zip file for a single directory, Linux returns a result for every file inside all three directories until the process has been completed.

5. Unzip your zip files in Command Line

(Image: © Future)

To extract files from your compressed directories, use the command unzip.

Enter your command in the format unzip <zip file name> if you want to extract to your current directory. 

If you want to extract files to a different directory, specify this in your unzip command using the format unzip <zip file name> -d /<directory location>

In the example above, I unzipped my compressed file to the Documents directory using the command unzip /..

The two dots (..) specify the directory immediately above the current one, which in this case is the Documents directory. You can also use the names of the directories in your command.

Mastering the art of zipping directories in Linux is a valuable skill for anyone seeking efficient file management and transfer methods.

Once you've mastered the basics of zipping and unzipping compressed files, you might want to explore some of the Linux zip command's more advanced features to enhance your file management capabilities. For example, -x allows you to exclude specific files or directories during compression, enhancing customization, and the -e option enables encryption, requiring a password for access.

However you choose to use them, you’ll find that zipping makes organizing, sharing, or archiving your directories a whole lot easier.

Why not take your Linux knowledge even further? We can show you how to find a file in Linux, how to rename a file in Linux and how to remove a folder/directory in Linux.

Emma Street

Emma Street is a freelance content writer who contributes technology and finance articles to a range of websites, including Tom's Guide,, and BestMoney. She has over 15 years of experience working in technical development within the fintech industry. When not writing about tech, Emma can be found writing romantic fiction, reviewing films, and updating her tea blog.