If you use Linux, you can password-protect any file, which is a good idea if you want to keep it in the cloud or carry it around in a hard drive.
We’ll use gpg, a component of GnuPG, to encrypt a file in Linux.
Run this command to encrypt the file using a password to secure it.
gpg -c filename.ext
The command’s result is:
$ gpg -c filename.ext
Enter passphrase:
Enter a strong passphrase that you can remember. Avoid using a simple one.
Next, you’ll receive
Repeat passphrase:
This will create an encrypted file called filename.ext.gpg. It will not delete the original file.
To decrypt the file run below command.
gpg filename.ext.gpg
The command’s result is:
$ gpg filename.ext.gpg
Enter passphrase
After entering the password the file will be recreated.