Back to how-to guides

How To Zip Files On Linux

Linux being an open source operating system allows various ways to zip files. In this guide, you will learn about the methods you can use to zip files on Linux . So let’s start the guide.

How to zip files in Linux Terminal

By default, Linux OS comes with zip file support. However, if the commands do not work, then use the following to install it:

sudo apt install zip

When you are done, run the following command in terminal, to create zip file.

zip output_filename file1 file2...

Second argument of the command is filename of the zip created as a result of this command, the arguments after it are all the filenames which you want to add to the zip file.

Password protected zip on Linux Terminal

To create password protected zip use the following command.

zip -p files_to_add

The second argument of this command is -p which will allow you to enter password for the zip file.

Using terminal is not a pleasant experience for every Linux user, therefore, I would like to guide about Graphical User Interface method for zipping in Linux.

  1. Locate the file(s) which you want to zip.
  2. Select the files and right click with mouse.
  3. From the menu, click on compress.
  4. Done. You have successfully created zip file for the selected files or folders.

We will also guide you on how to make password protected zip on Linux.

How to make password protected zip on Linux GUI

  1. All the steps from 1 to 3 are same as above guide, but, to ensure a password protected file, click on others option to explore more options about the zip file.
  2. Here you will option to set any password for zip file.
  3. Enter the desired password and click on Create.

BZIP2 method

BZIP2 is another utility distributed in Linux Operating systems. It is faster than GZIP but requires more ram to compress the files.

bzip2 -z file.txt

GZIP not only provides utility to compress the files but also support uncompressing.