20 C
Guru Unix /Linux and GNU supporter

How To Encrypt Files On Linux

Encryption is a method that makes a data unreadable to others and ensures that only the person meant to read the data reads it. It’s very powerful and useful method that’s used everywhere on the internet. In other words, security is now encryption. If you’re on Linux, you have the upper hand if you want to encrypt your files and keep them safe.

In this age of cyber warfare, no data is safe. For staying secured, I recommend encrypting the important and sensitive documents so that others can’t read them. Here’re a few methods that you can use to encrypt your files on any Linux system.

  • GPG (GnuPG)

It’s one of the best and easiest tools to use for encrypting and decrypting your files. It’s a CLI-based tool, but don’t fear; the commands are really simple to understand.

  • Open a terminal by pressing CTRL + Alt + T.
  • Go to the file’s directory that you want to encrypt. For example, I’m using “test_doc.txt” file on my desktop. So, I have to run this command:
cd ~/Desktop
  • Now, encrypt the file using the following command:
- Advertisement -
gpg2 -c test_doc.txt

Note that there are two versions of GPG (gpg and gpg2). Gpg2 is recommended as it’s better and improved. You’ll be asked to provide a password

If you want to decrypt the file, use the following command:

gpg2 test_doc.txt.gpg

Voila! Your file is encrypted using your own password. Feel free to delete the original file, as it will not be needed anymore. The file is already inside the .GPG archive.

  • mCrypt

This is another CLI-based tool for Linux. It doesn’t come by default with Linux distros, so you have to install it on your own. Depending on your Linux distro, install mCrypt using the following method:

sudo apt install mcrypt                      [Ubuntu + Ubuntu-based distros]
sudo apt-get install mcrypt                  [Debian]
sudo dnf install mcrypt                      [Fedora]
sudo zypper install mcrypt                   [OpenSUSE]

Now, the working method. It’s really simple and fun. It also supports multiple files at the same time.

  • Go to the directory where your file is. Here, I’m using the same file, the same directory as before (“test_doc.txt” on Desktop).
  • Run this command:
mcrypt text_doc.txt

If you want to add multiple files, follow this structure:

mcrypt file1 file2 file3

It’s time to decrypt the files.

  • Go to the directory where the encrypted files are.
  • Run the following command:
mcrypt -d test_doc.txt.nc

If you’re decrypting multiple .NC files, use this structure:

mcrypt -d file1.nc file2.nc file3.nc

Your files are back!

  • File Manager

Every file manager that comes with every Linux distro contains a good & functioning app. Using the file manager, you can create a password-protected ZIP file that contains all the files.

  • Select the files you want to encrypt.
  • Right-click and select “Compress” (or equivalent option).
  • Enter a password for the ZIP file.

  • Click “Create” (or equivalent).

Note that depending on your distro, the options and figure will vary, but the basic will be the same.


Make sure that you don’t forget the password! Never, ever! If you forget the password, there’s no way of recovering it (in your lifetime).

So, have some fun with your privacy! But Firefox seriously messed up privacy with their poor system design. Learn about the Firefox “Master Password” flaw that puts lots of users at stake.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


Please enter your comment!
Please enter your name here

Latest article