How to password protect a file in Linux

To password protect a file in Linux use the command below:

vim +X cpanelplesk.txt

+X option will make your file password protect.

vim +X cpanelplesk.txt
"cpanelplesk.txt" [New File]
Enter encryption key:
Enter same key again:

Now write anything you want and save it using !wq
"cpanelplesk.txt" [New][crypted] 0L, 0C written

Done.