In this post, we will see how to password protected a zip file using command line so that even if the anyone outside gets access to that zip file, can not unzip it without providing the password.
zip -ejr <new_zip_file_name.zip> <directory_name_to_zip>
[new_zip_file_name.zip: name for the zip file to create.
directory_name_to_zip: The source directory to zip]
Example: zip -ejr folder.zip zip_folder
e (encryption), ask for a password to create password protected zip file.
j (junk the path), will not include the folder hierarchy inside zip file because of zip command by default archives the complete folder hierarchy leading to your target folder.
r (recursive), will force the zip command to include the entire contents of the folder in the archive.