How to Encrypt Files in Linux

Method 1 of 2:

Encrypting a File

  1. How to Encrypt Files in Linux Picture 1
    Install GnuPG first. Open the terminal and enter the command sudo apt install gnupg. The installation process will start.
  2. How to Encrypt Files in Linux Picture 2
    Navigate to the folder where you store the file that you are going to encrypt. Right-click and choose Open Terminal from the menu.
  3. How to Encrypt Files in Linux Picture 3
    Enter the the command gpg -c file1.txt, and press Enter. Replace "file1.txt" with the name of the file you want to encrypt.
  4. How to Encrypt Files in Linux Picture 4
    Enter the passphrase. You can choose any suitable passphrase you want; it will as you to re-enter the phrase for the confirmation. Don't forget the phrase!
  5. How to Encrypt Files in Linux Picture 5
    Remove the original file by typing the command rm file1.txt. Replace "file1.txt" with the right file name. Your encrypted file will be created with the extension ".gpg" in the same directory.
  6. How to Encrypt Files in Linux Picture 6
    Reload the agent. Sometimes GnuPG will cache your passphrase, meaning anyone can decrypt the file without the passphrase. To avoid this, use the command gpg-connect-agent reloadagent /bye.
Method 2 of 2:

Decrypting the File

  1. How to Encrypt Files in Linux Picture 7
    Open the terminal to the folder where your encrypted file is located. The file has the .gpg extension. Just copy the name of the file from there.
  2. Type the command gpg file1.txt.gpg. Remember to type your file name instead of "file1.txt.gpg".
  3. How to Encrypt Files in Linux Picture 8
    Enter the passphrase.
  4. Wait for your original file to be generated. Then you can open it!
4.5 ★ | 2 Vote

May be interested

  • How to Use KUserPhoto of How to Use KUser
    kuser is an application used in many linux distros to create, delete, or manage user accounts. these instructions assume you are using the kde 4 version (the more recent version). click the 'add' button on the top toolbar.
  • How to Change the Position of the Wbar Dock in AV LinuxPhoto of How to Change the Position of the Wbar Dock in AV Linux
    in the latest av linux version, the wbar dock is located at the top of the screen. this can be quite annoying to those who are use to using it from the bottom. this small problem can be quickly solved by following the steps below. open...
  • How to Set up Php on Apache 2.2.3 on CentOS 5.3Photo of How to Set up Php on Apache 2.2.3 on CentOS 5.3
    this article is aimed at people who have centos 5.3 and apache 2.2.3. it may also work on rhel (but you have to pay for rhel). connect to your vps using ssh to get a command line (unless its being installed on your local machine). your...
  • How to Send Mail in LinuxPhoto of How to Send Mail in Linux
    this wikihow teaches you some basic ways to send email on your linux desktop system. if you're using a desktop version of linux like debian or ubuntu, the operating system comes with a built-in graphical mail app called thunderbird. if you...
  • How to Start a Prboom Multi Player Game in LinuxPhoto of How to Start a Prboom Multi Player Game in Linux
    this is how to start a prboom multi-player game in linux from the terminal inside of the gui. this tutorial is for playing over a local area network (lan) with up to 4 players. make sure you do it from the terminal from inside the gui. if...
  • How to Install Software on LinuxPhoto of How to Install Software on Linux
    this wikihow teaches you how to download and install new apps on your computer, using a linux operating system. in most linux distributions, there is a dedicated app that comes with a simple graphical user interface (gui) for installing...