How to password protect a zip file in Linux

If you need to password protect a zip file, look no farther than the zip command itself.

How to password protect a zip file in Linux

When you create a compressed zip file, chances are you might have sensitive information tucked inside that newly created archive. Should that be the case, the last thing you want to do is send that unprotected file to someone else, only to have it intercepted and the contents viewed. 

To prevent that, you can use the built-in encrypt option with the zip command. It's incredibly easy to use and should be one of your go-to options for zipping confidential files. 

Let me show you how this is done. This will work, regardless of what distribution you are using, so long as you have zip installed. 

SEE: Windows 10 security: A guide for business leaders (TechRepublic Premium)

How to password protect a file with zip

  1. Open a terminal window and create a practice file named testing. Create that file with the command touch testing. 
  2. Zip and encrypt that file with the command zip--encrypt testing. 
  3. You will be prompted to type and verify a password for the newly-created (and encrypted) file. 
  4. Once you've verified the encryption password, the zipped file is created and you can send it away. 

Make sure you share the encryption password with whomever you send the file to (probably in a separate message or phone call), otherwise they won't be able to decompress the file. In order to decompress the password-protected file, type the command unzip 

You will be prompted for the encryption password. Once you successfully authenticate with the password, the file will be decompressed and is ready for viewing. And that's all there is to it. Enjoy that added layer of protection.

Also see


Image: Jack Wallen

By Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic, The New Stack, and Linux New Media. He's covered a variety of topics for over twenty years and is an avid promoter of open source. For more news about Jack Wallen, visit his website jackwallen....