How to create and password protect a ZIP file on macOS/Linux using the command line

I was in need of password protecting a ZIP file on macOS, but couldn’t find an intuitive way to do so. Luckily we can do it on the terminal. This works with both macOS and Linux.

$ zip -er protected.zip ANY FILES YOU WANT TO ADD

This command will prompt you for a password to protect the ZIP file with. The result will be an encrypted file.

Scroll to Top