Create a Password Protected ZIP File in Linux

Last updated on Dec 28, 2019 in Linux

With zip utility, you can protect a zip file with a password. There are two options to do that, of which the other one is highly insecure.

Insecure Way

$ zip -p xyz123 myfile.txt

The p stands for password which is entered as a next argument. As you can see, this command is stored in history so the password can be seen in plain text format afterward. This method is not recommended

Secure Way

$ zip -e myfile.txt
Enter password:
Verify password:
  adding: myfile.txt (stored 0%)

The e stands for encryption. The password is prompted interactively and it is not echoed. The password prompt is repeated to ensure there is no typing errors.

To unzip password protected zip file, just unzip the file normally and enter the password when prompted: Unzip File in Linux