Encrypt / decrypt files using GPG

To install GPG on your Debian/Ubuntu/Mint Linux operating system use command:

sudo apt install gpg

Simple encrypt command with password:

gpg -c [FileName.txt]

Simple decrypt encrypted file with gpg:

gpg -o [FileName.txt] -d [FileName.txt.gpg]

This command decrypt enctypted file FileName.txt.gpg into normal file FileName.txt

Encryption using a key pair (asymmetric encryption):

Default GPG folder is: /home/user/.gnupg. Generate private and public keys:

gpg --full-generate-key

Answer the several questions (encryption type: RSA, keysize: 4096 for better encryption, key expiration time, your name and email address) and press “O” if all changes are correct.

To view public keys use command:

gpg -k

To view secret gpg keys use command:

gpg -K