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

  • File Management in Unix / LinuxFile Management in Unix / Linux
    all data in unix is ​​organized in files. all files are organized in folders. these directories are organized in a tree structure that is called the file system.
  • Is it possible to run .exe files on Linux?Is it possible to run .exe files on Linux?
    you don't need to trade the appeal of windows software for the stability, security, ease of customization (and even great classic appearance) of linux. in this article, you will be shown how to run windows exe (possibly executable) files and software using the linux operating system. these methods can be applied to any linux distribution, including ubuntu, kali linux, centos and many others.
  • How to share encrypted files and self-destruct on Otr.toHow to share encrypted files and self-destruct on Otr.to
    otr.to is a self-destruct file sharing service and conducts file encryption according to aes 256-bit standard. the file will automatically delete after the time that the user has selected.
  • How to use pandoc to convert files on LinuxHow to use pandoc to convert files on Linux
    you can use pandoc on linux to convert over 40 different file formats. you can also use it to create a simple docs-as-code system by writing to markdown, saving with git and exporting it in any supported format.
  • How to create new files in LinuxHow to create new files in Linux
    there are a number of different linux applications and commands that will create new files for you, even without launching the application. the method you use will depend on your purpose for the file. let's take a look at the options so you can see which one is most useful for you!
  • How to Create ISO Files on LinuxHow to Create ISO Files on Linux
    today's tipsmake will show you how to turn multiple files into one iso file on a linux computer. you need to use the linux command line to do it.
  • How to encrypt FILE or FOLDERS on Windows 10, 8, 7How to encrypt FILE or FOLDERS on Windows 10, 8, 7
    how to encrypt files on windows 10? instructions on how to enable file or folder encryption available on windows operating system
  • How to Find Files in LinuxHow to Find Files in Linux
    if you don't know how, finding files in linux can be quite difficult. here, the best way is to use a few different terminal commands. they are much more powerful than the simple search features on other operating systems, and when you know how to use them well, you will have complete control over your files.
  • How to encrypt 256-bit AES files right on Chrome browserHow to encrypt 256-bit AES files right on Chrome browser
    to be able to encrypt 256-bit aes standard files on chrome, the browser needs to install an extension called lock it up: password protect files.
  • How to copy and rename files in LinuxHow to copy and rename files in Linux
    there are more ways to copy and rename files on linux than just cp and mv. try some commands and other ways suggested below.