Linux Commands

How to create a password protected zip file on Linux

In the computing era, the data must be secure enough as it has to revolve around multiple machines around the globe. Password protection is the primary aspect to ensure the secure transmission of files or data.

The zip is a file format that compresses the file, and this file format serves various purposes, such as combining multiple files into a single file to make it easy to transfer.

Like most of the tasks on Linux can be carried out using CLI and GUI, similarly, a password protected zip file can also be created using both ways. This article provides the command line and graphical method to create an encrypted zip file on linux.

How to create a password protected zip file using CLI

The following steps would lead you to creating a password protected zip file on Linux.

Step 1: First open the terminal and write the following command to install the zip, and unzip command line tools (if not installed).

$ sudo apt install zip unzip

Text Description automatically generated

Step 2: The “-e and –encrypt” parameters would assist you to set a password for your zip file. For instance, the command provided below will create a zip file named linuxhint that contains two files (linux.txt and debian.txt).

$ sudo zip --encrypt linuxhint.zip linux.txt debian.txt

Graphical user interface, text Description automatically generated

Note: The command in step 2 would create a password protected zip file in the current working directory and the files contained by it also lie inside the present directory.

To include the files from other than the current directory, you have to give the complete path of the files as we did in the following command.

$ sudo zip --encrypt -r info.zip /home/adnan/Desktop/linux/

Text Description automatically generated

Note that all the files and directories from the specified target folder are added to the zip file named info.zip.

Step 3 (Optional): You can unzip the .zip files as we did in the below-mentioned command.

$ sudo unzip -r info.zip

Text Description automatically generated

The output shows that the zipped file was protected, and the extraction is performed after entering the password set for that file.

Note: If in case you have entered the wrong password, you would not be able to extract files as can be seen in the following image.

Text Description automatically generated

How to create a password protected zip file using GUI

To create the password encrypted zip file using a graphical interface, the following steps are recommended to follow.

Step 1: Click on the “Show Applications” icon placed on the dock or press “Super Key + A” to open the applications menu.

A picture containing graphical user interface Description automatically generated

Step 2: Search here for “Archive Manager” and click on it to open:

Graphical user interface, application Description automatically generated

Step 3: Click on the three lines placed on the menu bar of the “Archive Manager” and click on “New Archive…“.

Graphical user interface, application Description automatically generated

After doing so, the following box will appear, where you have to ensure the following content.

– extension must be set to “.zip

– set a Filename, Location and Password for that zip file

At the end, click on “Create” to accomplish the process.

Graphical user interface, text, application Description automatically generated

Step 4: Once the file is created, click on the “+” icon to add files in the zip file.

Graphical user interface, application Description automatically generated

After adding files, click on the “Extract” button placed on the menu bar.

Graphical user interface, text, application Description automatically generated

The time you click on the “Extract” button, you have to choose the extraction location. After doing so, a dialogue box will appear which requires a password for completing the extraction process as shown in the following image.

Graphical user interface Description automatically generated

As shown in the output, the password dialogue shows that the file is now protected with some password.

Conclusion

The password protected zip file can be created using the zip and unzip command line tool. Moreover, the graphical interface of Linux can also be exercised to create a password protected zip file. This guide outlines the methods and steps that are recommended for the creation of a password protected zip file. A terminal enthusiast may prefer the CLI method over GUI as it is fast and easy to adopt. However, a novel Linux user may adopt a GUI method to do the same process.

About the author

Adnan Shabbir