There are quite a few blog posts and StackOverflow threads covering this, but somehow, I had difficulty finding the answer I was looking for on Google. As such, I’m publishing this for my (and now your ) reference…
To password protect a file simply run the
zip command and supply the
-e flag (which is short for
--encrypt). First pass it the “destination” (e.g. file.zip) and next pass it the source (e.g. file).
$ zip -e file.zip file
zip man pages you’ll be prompted to input (and verify) the encryption password.
Unzipping the file will require the user to supply the encryption password you used to encrypt the zip file.
It’s also worth noting that if you enter the same file name for both the source and the destination,
zip will automatically append
.zip to the destination file name.
$ zip -e file file
Password protecting folders is more or less the same, but requires supplying one additional flag to the
-r flag (short for
The command looks something like this…
$ zip -er folder.zip folder
Some guides you’ll find suggest doing
zip -e folder.zip folder/*, but this technique will not work if there are subfolders inside of
Hi, I'm Max!
If you'd like to get in touch with me the best way is on Twitter.