How to Create a Password Protected Zip File in Linux

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

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.

  • Create password protected zip file in Linux command line
  • Create password protected zip file using Nautilus file manager [GUI method]

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

Create password protect zip file in Linux command line

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.

Create a password protected zip file in Linux using GUI

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.

Search for Archive Manager and open it.

Archive Manager Ubuntu
Archive Manager

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

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

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.

There are other ways to password protect folders in Linux. This tutorial shows how to do that.

How to Password Protect a Folder in Linux
Got some special files to save from prying eyes? Learn how to create password protected folders in the Linux desktop.

I hope this quick tutorial helped you to create password-protected zip files in Linux.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.