How to Create a Password Protected ZIP File in Linux

You can use the zip command to compress files with a password. This post helps you to create and open password-protected ZIP files in Linux.


Table of Contents


What is the zip Command?

The zip command helps you:

  • Compress files to save space.
  • Protect files with a password for added security.

To unzip (extract) files, you’ll use the unzip command. Both are simple to use once you install them.


Step 1: Install the zip and unzip Commands

If your system doesn’t already have zip and unzip, you can install them. Here’s how:

sudo apt install zip unzip

Step 2: Create a Password-Protected ZIP File

To create a ZIP file and protect it with a password, use the following command:

zip -re OUTPUT_FILE.zip FOLDER

Note: You’ll be asked to set a password. Type it carefully and press Enter. Your ZIP file is now created and protected.

Here in the above command:

  • -r : Compresses all files in a folder, including subfolders.
  • -e : Enables password protection.
  • OUTPUT_FILE.zip: Name of the ZIP file you’re creating.
  • FOLDER: The folder you want to compress.

Check the File:

To make sure your ZIP file was created, run:

ls

You should see output_data.zip in the list.


Step 3: Open a Password-Protected ZIP File

To unzip a password-protected file, use the unzip command:

unzip output_data.zip

You’ll be prompted to enter the password. Once you enter it, the files will be extracted.

Using the zip command in Linux is a simple and effective way to compress and protect files. By following this guide, you can easily compress files and protect them with passwords using the zip command in Linux. The steps outlined for creating and extracting password-protected ZIP files ensure secure and efficient file management. The zip command in Linux is a versatile utility used for compressing files and directories into a single archive file, often with a .zip extension.