If you have a folder that’s full of files and need to send it to someone or otherwise store it efficiently, archiving the folder into a .zip file is a good way to do it. Of course, on Linux systems, it’s probably more common to come across compressed tar files, but zip archives are still ubiquitous and a perfectly viable choice.
In this guide, we’ll show you how to compress (or “zip”) a folder on all major Linux distributions. We’ll be covering the steps for doing so on the command line as well as from the GNOME and KDE graphical desktop environments. Choose whichever method you find most appropriate when creating your zip file.
In this tutorial you will learn:
- How to zip a folder from Linux command line
- How to zip a folder from GNOME GUI
- How to zip a folder from KDE GUI
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | zip |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Installing zip on Linux
Before diving into the instructions, you’ll first need to make sure that the zip utility is installed on your system. You can check by typing the following command in terminal.
$ zip -v Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license. This is Zip 3.0 (July 5th 2008), by Info-ZIP.
If you find that the zip tool isn’t installed, refer to our guide on how to use zip on Linux for instructions on installing it on all major distros.
Zip a folder from command line
Use the following zip command syntax with the -r
(recursive) option to zip a folder from command line.
$ zip -r archive-name.zip folder-name
The folder and its contents will be output to your terminal. This is confirmation that the zip utility has compressed your files and added them to the archive successfully.
You can specify relative paths to files (as seen above), or absolute paths, like in this example:
$ zip -r /path/to/archive-name.zip /other/path/to/folder-name
Also feel free to specify multiple directories in your command or include individual files. Everything will be compressed into a single zip archive.
$ zip -r archive-name.zip folder1 folder2 file1.txt file2.txt
Zip a folder from GNOME GUI
Use the following step by step instructions to zip a folder in GNOME desktop environment.
- Use GNOME’s file browser to navigate to the folder you wish to zip.
- Right click on the folder (or folders) and select “compress.”
- On the next menu, make sure .zip is selected as your option, type the name you wish to give to the zip file, and click create.
Your zip archive will be created in the same directory in which your folder resides.
Zip a folder in KDE GUI
Use the following step by step instructions to zip a folder in KDE desktop environment.
- Use KDE’s Dolphin file browser to navigate to the folder you wish to zip.
- Right click on the folder (or folders) and select Compress > Here (as ZIP).
Your zip archive will be created in the same directory in which your folder resides.
Conclusion
In this guide, we saw how to zip folders in Linux from the command line, as well as from the GNOME and KDE desktop environments. Zip files are the most used compression format, so it’s very useful to know how to compress folders into zip files for storage or sharing with others.
We have a separate guide for unzipping a zip file if you need to learn how to open these zip archives later.