monovm

Follow MonoVM
on social networks
and stay updated
with our new posts.

instagram twitter linkedin Youtube facebook telegram
English
+370 5 205 5502 sales@monovm.com

How to Zip and Unzip Files and Folders in Ubuntu?

Learn how to zip and Unzip files and folders in Ubuntu easily with our step-by-step guide. Discover various command line and GUI options for zipping and unzipping files, including the popular tar and gzip tools.

20 Jan, 23 by Susith Nonis 6 min Read

List of content you will read in this article:

Encountering zip files usually tempts us to archive our files in a folder, as we can save disk space and network bandwidth. Zip files and folders in Ubuntu help us compress multiple files into one. But you may not know how to do that. This article reviews convenient methods for zipping files and folders in Ubuntu.

The standard tar and gzip utilities created many Ubuntu Linux file archives with the "tar.gz" extension. Although gzip has the same name as Windows' built-in file extractor, PKUNZIP, WinZip, or 7-Zip, it does not produce compressed archives compatible with these utilities. Linux and non-Linux systems, such as Windows and Mac OS X, can extract standard archives created by Ubuntu's zip command line utility.

Follow the steps below to zip the file in Ubuntu:

Step 1:

Tap on the "Dash" icon, and in the search box, type "terminal". The "Terminal" application icon will appear. Click on it.

Step 2:

Use the "cd" command to navigate to the zip file's folder. When you are at the command prompt, type "cd Documents" and press Enter if your file is located in the "Documents" folder.

Step 3:

Ubuntu's terminal command line allows you to create a zip archive, add files to the archive, and build the zip archive by typing the “zip” command. For example, to create a zip archive named “moneydocs” that contains the file "bank.doc", type the following commands at a terminal prompt and then press the "Enter" key:

zip moneydocs bank.doc

Step 4:

Now you need to confirm that your zip file has been created. To do so, type "ls *.zip" at the command prompt. Then tap the “Enter” key.

In addition to creating zip files, compressing a folder in zip format is essential for sharing multiple files with someone else. Zip folders are offered to prevent the loss of our data in operating systems, so you should learn how to zip a folder in Ubuntu. 2 methods for zipping a folder in Ubuntu are using the Gnome graphical interface environment and using the command line. First, let`s start with the command line zipping method:

1.   Zip folder in Ubuntu using the command line

To zip a folder in Ubuntu, the zip command-line utility must be installed on your system, as it`s necessary for file compression. So, before anything, check if it has been installed on your system. There is no default installation of this zip utility in most Linux distributions.

You can use the Ubuntu official apt repository if you need to install the zip command-line utility. Typing the command mentioned below helps you to install it too:

$ sudo apt update

$ sudo apt install zip

Now that you have installed the zip utility use the command below to check the installed version:

$ zip –version

You can zip a folder with the zip utility using the syntax below:

$ zip options archive-name.zip folder-name

For instance, if you want to zip a folder named ‘MyFolder’, the below-mentioned syntax will create a zip archive of this folder:

$ zip -r MyFolder.zip MyFolder

Upon successfully compiling all files with the zip utility and adding them to the .zip archive, the directory's contents will be displayed on the terminal.

How to zip multiple folders in Ubuntu

Multiple files and directories can be included in the same zip archive, as well as multiple directories and folders. If you want to create multiple zip archives, use the following command:

$ zip -r archivefolder.zip MyFolder1 MyFolder2 file1.txt file2.txt

$ zip -r MyDocsFolder.zip MyDocsFolder PersonalFolder file1.txt file2.txt file3.txt

How to create a zip file with a password in Ubuntu

You may have private or sensitive files and information you want to keep secure. We mention a command that needs a verification password to access files. For storing your private files, use this command:

$ zip -e  archivename.zip directory_name

Create split zip files in Ubuntu

Occasionally, you need to upload files that are only 100 kb in size to another server or file hosting service. For instance, you have 2 MB of data to upload, but it only supports 100 kb files.

By using the option '-s' followed by the specified archive file size limit, you can create a split archive file. Once you reach the specified archive file size limit, the below command creates a new zip archive file in the home directory.

$ zip -s 100k -r archivename.zip directory_name

2.   Zip folder in Ubuntu using Gnome GUI

Another method of zipping a folder in Ubuntu is using the Gnome graphical desktop environment. If you can`t use the command line, perform the following steps:

  1. You can zip a folder using the Gnome desktop and navigate to that folder.
  2. Select the folder by right-clicking on it. A drop-down list will appear; select the 'compress' option from the list.
  3. Click on 'Create' after selecting the '.zip' extension and giving the zip archive a suitable name.

Now you can see that the compressed archive is created in the current directory where the main folder is located.

Compressing files always helps us to save disk space and bandwidth. It`s also useful for sharing multiple files with others in a convenient way. Now you can zip files and folders in Ubuntu as we explained the methods to create them using the command line and Gnome graphical desktop environment. To choose a suitable method, you must take into account your requirements. I hope the information about zipping a folder using the zip command will be helpful for you.

People also read: 

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.