If you have any personal or sensitive files stored on your Linux machine, you should consider encrypting them with GnuPG for added security.
Nowadays, the news about hacking, ransomware, and data breaching has become very common. Therefore, it is important to be very careful in protecting personal files and sensitive data.
On Linux, you have GnuPG, a simple and comprehensive encryption tool that you can use to secure important data on your system.
What is GnuPG?
GnuPG or simply GPG is an encryption technology that has gained wide popularity due to its ease of use and superior security algorithms. It is an open source implementation of the Open PGP standard.
Linux provides you with a GnuPG command line tool to help users learn about GPG encryption and security keys. Aside from encrypting and securing files, GPG is also used to secure software and package downloads.
GitHub also gives you the option to use GPG as an alternative method to traditional SSH keys.
Install GnuPG on Linux
GPG is installed by default on most Debian-based distributions like Ubuntu and Lubuntu, but in case you don’t, here’s how to install GnuPG on your system:
On Debian-based distributions:
sudo apt install gnupg
On RHEL, Fedora, and similar distributions:
sudo yum install gnupg
On arc-based distributions, switch to the root user with so And run the following command:
pacman -S gnupg
Encrypt a file with GnuPG on Linux
You can use GPG to encode any file format. Let’s say you have an important file that contains your organization’s salaries; You obviously don’t want other people to look at this sensitive data.
The file data looks like this:
To encrypt the file, simply run the command with format gpg -c filename. For example, let’s encrypt files payroll. xt, which is a text file located in the current working directory. Feel free to use any file to continue.
gpg -c salaries.txt
The system will prompt you to provide a passphrase. Enter a secure passphrase and continue.
GPG will create another file with the extension .gpg Extension of the file to the original file name. If you run the ls command in your docs directory or wherever your file is, you’ll notice that GPG has created an additional file.
Run the cat command to view the newly encrypted GPG content, and you will get an ambiguous text, which means that your data is now encrypted.
To view the contents of the file, you will first need to decrypt it with GPG using the command:
gpg -d salaries.txt.gpg
You can now safely delete the unencrypted file using the rm command.
Secure your messages and files with GPG on Linux
GnuPG is a great tool to encrypt and password protect your data on Linux. If you have sensitive data on your computer, you should consider encrypting it.
Aside from securing sensitive files with GPG, you can take your security awareness a step further and encrypt communication messages transmitted over the Internet using GPG key pairs.