How to Create a Password Protected Zip File in Linux

Brief: This simple tutorial shows you how to create a password protected zip file in Linux both in command line and graphical way.

We have seen how to password protect folders in Ubuntu earlier. We have also seen encrypted text editor for Linux. Today, we’ll see how to create password protected zipped files in Linux, in both command line and graphical way.

I am using Ubuntu in this tutorial but you can use any Linux distribution that uses Nautilus (now called Files) file manager for the graphical part. Command line steps are the same for any Linux distribution.

There are several ways you can encrypt zip file in Linux. In fact, there are dedicated command line tools for this task, but I am not going to talk about those. I am going to show you how to password protect a zip file without installing a dedicated tool.

Create password protect zip file in Linux [Command Line Method]

First thing first, make sure that you have zip support enabled in your Linux system. Use your distribution’s package manager and try to install it. If its not installed already, it will be installed.

In Debian/Ubuntu, you can use this command:

sudo apt install zip unzip

Now, let’s see how to password protect a zip file in Linux. The method is almost the same as creating zip folder in Linux. The only difference is the use of option -e for encryption.

zip -re output_file.zip file1 folder1

The -r option is used to recursively look into directories. The -e option is for encryption.

You’ll be asked to enter and verify the password. You won’t see the password being typed on the screen, that’s normal. Just type the password and press enter both times.

Here’s what the process looks like on the screen:

zip -re my_zip_folder.zip agatha.txt cpluplus.cpp test_dir
Enter password:
Verify password:
adding: agatha.txt (deflated 41%)
adding: cpluplus.cpp (deflated 4%)
adding: test_dir/ (stored 0%)
adding: test_dir/myzip1.zip (stored 0%)
adding: test_dir/myzip2.zip (stored 0%)
adding: test_dir/c.xyz (stored 0%)

Do note that if someone tries to unzip this file, he/she can see the content of the folder such as which files are there in the zipped file. But the files cannot be read.

Recommended Read:

Create a password protected zip file in Linux [GUI Method]

I have created a password protected zip file in Ubuntu 18.04 here but you can use the same steps on any Linux distribution with GNOME desktop environment.

Step 1:

Search for Archive Manager and open it.

Archive Manager Ubuntu
Archive Manager

Step 2:

Drag and drop the file(s) you want to compress into a zip file. Select Create Archive option here.

Create Archive Ubuntu 1
Create a zip file

Step 3:

In here, choose the type of compressed file. It will be .zip in my case. You’ll see the “Other Options”, click on it and you’ll see the password field. Enter the password you want and click on the Save button.

Creating Password Protected Zip file in Ubuntu Linux
Create Password Protected Zip file

That’s it. You have successfully created a password protected zip file in Ubuntu Linux graphically. The next time you want to extract it, it will ask for a password.

Password Protected Zip file in Ubuntu
Password Protected Zip file in Ubuntu

If you are using Ubuntu 16.04 with Unity desktop environment, things will be slightly different. Click on the next section to see the steps for Unity desktop.

Create password protected file in Ubuntu 16.04 Unity

To follow this tutorial, you just need to make sure that you are using Nautilus/Files file explorer. If you are using Fedora, Ubuntu Unity, or any other Linux distribution with GNOME as its desktop environment, you have Nautilus.

Step 1

Right click on file(s) and/or folder(s) and click on Compress:

Password protect a zip file in Ubuntu

Select the compression format you want to choose. There are several formats available but you cannot use all of them for password protecting the files.

Step 2

I advise to use the .zip format. After selecting the compression format, click on the Other Options.

Encrypt files in Linux

Step 3

You’ll see option of entering password in Other Options. If the compression format you selected doesn’t support encryption, this Password area would be greyed out.

It may also happen that you’ll have to install the compression utility to use the encryption. For example, if you do not have RAR installed, password option will not be available.

In Other Options, put password in folders

Step 4

Enter a suitable password and click on Create:

Creating encrypted folders in Linux

Compression takes time based on the size of the file or directory. You’ll see a message like this when the files are compressed successfully:

Successfully compressed files in Ubuntu Linux

The compressed file thus created is password protected. If you try to extract it, it will ask you to enter the password:

Password protected folder in Ubuntu Linux

As you can see, no one (in normal ways) can extract this file without the password. Congratulations, you just learned how to encrypt zip files in Ubuntu Linux.

Just for your information, double clicking on the password protected directory might give the impression that you may access the encrypted directory without a password, but you cannot actually read those files.

I hope this quick tutorial helped you to create password protected zip files in Linux. In coming days, we shall see how to password protect a directory in Linux and how to break the encryption. Stay tuned :)

Similar Posts

  • Abhishek
    good idea to document this. The shorter, the better (See Shakespeare).
    When Zipped and encrypted under Linux, will it be possible to open and unzip the file with the standard Windows Winzip etc…?
    Sorry, I don’t have a window machine to try.
    A.

    • Hello Andre,

      “When Zipped and encrypted under Linux, will it be possible to open and unzip the file with the standard Windows Winzip etc…?”

      Considering zip is cross-platform, I would presume that it should work on Windows as well. I haven’t tried it personally though.