How to Encrypt a File in Linux

Category: Tech

How to Encrypt a File in Linux

In the modern world, nearly every aspect of your identity is recorded on the computer. One way to protect your most sensitive information is to use file encryption. When you encrypt a file, the contents of the file are shuffled and hidden in excess data according to a fixed algorithm so they appear random to anyone without the password necessary to decode the information. Linux computers have a built-in encryption tool, Gnu Privacy Guard, that can be used to encrypt any file from a command-line terminal.


  • Open a command-line terminal from the taskbar.

  • Run the encryption program using the following command, substituting the name of the file you wish to encrypt for "filename:"

    gpg -c filename

  • Enter a password of your choice when prompted. The encrypted contents of your file will be stored in the file "filename.gpg."

  • Access your encrypted data using the following command, inputting your password when prompted:

    gpg filename.gpg

  • Article Source: