Ways To Encrypt Files In Linux


Table of Contents

Ways To Encrypt Files In Linux

One of the most important things for any user is the security, if a user is running a vulnerable system, his information is in danger. If you want to have your information insured, you must do more than having a strong operating system, you must encrypt your files.
There are a lot of software to encrypt files, but we’re in Linux. In this article, you’re going to know the most popular and secure ways to encrypt your information.
encrypt files in linux

GNU Privacy Guard

GNU Privacy Guard, most known as GPG is an implementation of OpenPGP standard. It has capabilities to encrypt and sign your data and communication, also it features a versatile key management system as well as access modules for all kinds of public key directories. It’s a command line tool, so if you’re looking for something with a GUI GPG isn’t your solution, but you can use another tool powered by GPG and featuring a graphical user interface.
gnupg linux file encryption

How to use GnuPG?

The first thing that you must do before use GPG is to install it. GnuPG is available for any operating system, even you can use it on Mac OSX or Windows.

Some Linux distros have GnuPG installed by default, but if your distro doesn’t have it installed you can get it through the package manager or compiling it from its source code.
Also, you should read the “mini-Howto”  about GPG.​GnuPG mini-Howto: http://www.dewinter.com/gnupg_howto/english/GPGMiniHowto.htm


I have created a file called “new.file” and I want to cipher it, so I have to use gpg as the following way –

encrypt file in gnupg

You can see that now I have the encrypted file “new.file.gpg” and if I want to see its content without decode it, I can’t do it.
cipher encryption files in linux

If a file is encrypted, any user can see its content only if he knows the password. So I’m going to decrypt it using the following command:
dcrypt files in linux

This is not the best way to encrypt a file because it’s based on the use of a symmetric key. GPG has a better way to encrypt using asymmetric keys, you should read the complete documentation about Gnu Privacy Guard.
I think that GnuPG is the best way to encrypt files in Linux for three reasons:

  1. It supports asymmetric keys.
  2. It supports the RSA and DSA algorithms.
  3. It is free.

If you think that GnuPG is very hard to use it, you have some alternatives:

  • GnuPG Shell

You can use it in Linux or Windows.

gnupg shell linux

  • Seahorse

It’s a frontend for the Gnome desktop environment.

  • KGpg

If you’re using KDE, KGpg is for you. It’s a GUI for GnuPG.

kgpg wizard in linux

If you don’t like GnuPG or maybe you think that it is very complex, you can other alternatives.


ccrypy is a replacement of UNIX crypt, it can encrypt files and streams and also it is supported by emacs to read encrypted files. ccrypt is based on the Rijndael block cipher.
It has the advantage that is supported by several operating systems:

  • Linux
  • Sun Solaris
  • Windows NT
  • Android 4+
  • FreeBSD
  • OpenBSD
  • NetBSD
  • Mac OS X (universal)

ccrypt is less complex than GnuPG and if you’re looking for a quick way to encrypt your files it’s a good alternative for you. ccrypt is developed by Peter Selinger, he’s a professor of mathematics at Dalhousie University.

ccrypt files in linux

Encrypt through compressed files

Another way to encrypt files is making a compressed file with a password. There are a lot of tools to decrypt a compressed file without know the password, but it is very difficult for most users.
If you want to encrypt your files using this way you have several options:


​It’s one of the most popular formats to compress files and also you can use it to keep save your information, just use the following command:

$ zip –password ********** file.zip files-to-add.ext

Also, you can use 7-zip if you want, but you must have installed the p7zip-full package on your system.
$ 7za a -tzip -p -mem=AES256 file.zip files-to-add.ext
encrypt files in zip

7-zip file encryption in linux

Other Tools to encrypt files

I think that the best way to encrypt files in Linux is GnuPG, but if you don’t like it or maybe don’t like any of the previous alternatives, you should see the following two tools:


Finally, I want to say you that the file encryption is a very important process because the security of your files is the most important, but remember any user needs more than an encryption tool to keep safe his files.