How To Zip A Folder In Linux Distribution Using Compression Levels

Creating a zip in the Linux distribution system can be done in two ways; one is the graphical method and the other one is command-line based method. In this how-to zip a folder in Linux guide, I will be guiding you with the different zip utilities and directory structure based zipping and unzipping folders in Linux. Additionally, we will see the compression level based zipping of the folder in the Linux distribution system.

Table of contents –

Installing Zip on Debian based Linux Distributions –

Before actually installing the zip utilities on Linux distributions, we first need to update the apt using the following command –

$ sudo apt-get update

The above command requires a lot of data, time, and space on your Linux distribution; You can skip this step if you are not facing any issues using the below command.

Now you can install the zip utilities using the following command –

$ sudo apt-get install zip unzip –y

Creating a Zip File based on the Compression Level –

To use the zip utilities based on the compression level; you can use the compression range (1-10); with 1 being the fastest compression but less optimal file and 9 being slow compression but optimal file. But you might now have a question which is the default compression when no level is specified? The answer is level 6 compression which is the default compression for creating a zip in the Linux distributions.

The zip command used with specific compression level is as follows –

$ zip -1 Desktop      /* Fast compression & Less Optimal file */

In the above code, we specified level 1 as the compression level which gives us faster compression and less optimal file. If you want to a more optimal file, you can specify level 9(Max) but it will take a lot of time for compression.

You can change the compression level by replacing the number 1 with a different single-digit number in the range of 1-9.

Also read: Things to do after installing kali linux in 2020 – Most Important

Creating a Zip file in the Working Directory –

There are two ways to zip a folder in Linux distributions:

  • Graphical method
  • Command-line method

Both methods can be used for creating a zip file in the working directory. But the graphical method is much simpler for zipping a directory structure and later extracting the zip file with one click. Moreover, if you have a good hand on the command line interface, you can readily go for it.

Also read: How to delete files and directories in Linux – Simple Guide

How to zip a folder in Linux (Graphical method) –

To create a zip file directory structure using the graphical method, use the following steps –

  • Go to the specific folder location on your Linux operating system.
  • Right-click on the folder to be zipped.
  • Select the compress option from the menu.
  • Now you have to enter the name for the zipped file and select the “.zip” option
  • The zipped folder is now created in the same directory.

Extracting the Zip File (Graphical method) –

Once you have created a zip file, you can use the following steps in extracting the zip file –

  • Right-click on the zipped file
  • Select the Extract here option from the menu

Note – Use extract here if you want to unzip all the files in the same directory structure; if you want to extract all the files in a different directory then select the “extract to” option and specify the path to the directory.

Also read: How to check the version of Linux?

Creating a zip in the working directory (command-line)

The command-line options are equally easy to use but require familiarity with Linux commands and their use. If these commands are not properly used, you may end up deleting the zip folder from your Linux system.

The following are steps to zip a folder in Linux using the command line method –

  • Open the directory where the folder is located.
  • Right-click in the window and open the terminal. Type the following command
$ cd /home/alpha
  • Here Alpha is the folder to be zipped in the home directory.
  • The following command is used to zip the folder where Alpha is the name of the final file and output is the directory.
$ zip -r $HOME/
  • The zipped folder is now created and can be found by using the ls command.

Also read: How to rename files and directories in Linux?

Extracting a Zip File (Command-line)

To extract a zip file using the command-line interface, use the following steps –

Change the working directory to where the zip folder is available & type the following command –

$ cd Directory_path

Here, the Directory_path is the location where we will be extracting the zip file.

The following command is used to locate the zipped folder.

$ unzip

Here, Alpha is the zipped folder.


To sum up, these are the best ways for creating a zip file on a Linux distribution; you can use both the graphical and zip command methods to zip a folder in Linux. Likewise, extracting the zip file involves the same two methods. Additionally, You can use the compression level along with the zip utilities to have a much optimal file in your working directory.

Subscribe to our newsletter or join the telegram channel for more amazing tech related content.

Previous Post
best websites to learn coding

Top 6 Websites to Learn Coding for Free in 2022

Next Post
kotlin vs java

Kotlin vs Java – Why Kotlin is better than Java?

Related Posts
Popup subscribe Form Tiny Quip


Some Catchy Line to Grab your Attention

Get Our Prime Content Delivered to your Inbox for Free!! Join the Ever-Growing Community… Right Now.