Password protect file using 7z in Linux from the terminal

This is a short post on how to password protect a file using 7z in Linux from the terminal.

Below is the sample command that encrypts file “file.txt” with password (Replace PASSWORD with your pass) and saves to encrypted zip file Protected.zip

7z a Protected.zip -pPASSWORD file.txt

Credits/References:

Stackoverflow