Blog Post
How to Encrypt Files and Folders on Linux

How to Encrypt Files and Folders on Linux

Is your work or personal life filled with sensitive information you want to keep private? In that case, password-protecting files and folders on Linux is a great way to ensure that your information stays safe.

Knowing how to password-protect files and folders on this open-source operating system is essential. After all, you never know when somebody might try to snoop around in your files.

Luckily, we will explore a few different methods in this article. So, let’s get started!

Protecting files and data online

Sometimes, the files in your Linux device can be as safe as they can be. The dangers arise when you decide to share such files online. For instance, you might exchange data through unsecured connections, possibly letting outsiders snoop on them.

Therefore, ensuring that the networks you connect are secure is crucial. Of course, it is easy when you use your home network. Sadly, when you join unknown networks, you can never know how secure they are. Therefore, consider a VPN download. Virtual Private Network encrypts internet traffic and secures your connection. Consequently, you can exchange files securely regardless of any network settings.

How to set a password on a folder

You can follow the below-given methods to protect the folders with a password.

1. Encrypting using GNOME EncFS Manager

The steps you need to follow to use GNOME EncFS Manager to encrypt the folders of your choice are as follows:

  • On your desktop, launch the applications menu and search for GNOME EncFS.
  • Click on the application to open it once located.
  • Once launched, navigate the toolbar, and tap on the (+) symbol.
  • You’ll see a dialogue box popping, choose the second radio button under “Directory or drive to encrypt or import” option and select a folder. Also, at this step, make sure you create a new empty folder here because later, you’ll be transferring your data from another folder to this one.
  • Afterward, select an appropriate location where you want to mount the encrypted folder.
  • In the same dialogue box, you’ll see a tab “Password.” Under that, there will be two blank spaces where you must enter a password.
  • After filling in the password, hit the Create button to create an encrypted folder.
GNOME EncFS Manager Interface on Ubuntu Linux

Once you’ve completed all these steps, GNOME EncFS Manager will create a stash (encrypted folder) and place it in the destination directory that you chose. To access the contents of the folder, double-click on the mounted drive. Moreover, to unmount the folder, simply uncheck the checkbox displayed on the right side. Or you can right-click on the encrypted folder and choose the ‘Unmount’ option.

Further, when you need to mount the folder, the GNOME EncFS Manager is bound to require the password you entered.

2. Use VeraCrypt

VeraCrypt is a useful free disk encryption tool that works on all major operating systems. You’ll have to download it to use it, and we advise you to do that from its official website only. Once you’ve downloaded and installed it, follow these steps:

  • Go to the applications menu and launch the VeraCrypt app.
  • Once launched, you’ll see an interface with a toolbar and some headings such as Slot, Volume, Size, Mount Directory, and Types.
  • Select the ‘Drive Slot’ and click on the ‘Create Volume’tab below.
  • Next, a VeraCrypt Volume Creation Wizard will appear. Click on the “Create an encrypted file container” option and click on ‘Next.’
  • After clicking next, the app will ask you to choose the volume type. Choose the “Standard Encryption” option and hit ‘Next.’
  • Then, click on the “Select File’ option and create a new file to store the encrypted disk.
  • An ‘Encryption Options’ window will appear next. Here choose one encryption algorithm and one hash algorithm and click ‘Next.’
  • Next, you must provide a volume size, and there will be an option to enter a password. Fill in the information and click ‘Next.’
  • Then, you’ll be asked to choose a filesystem. Simply select the one you want from the drop-down.
  • Lastly, click on ‘Format’ to create a volume.
VeraCrypt Mounting Interface on Ubuntu Linux

To access this encrypted volume:

  1. Return to the VeraCrypt main window and click “Select File” under Volume.
  2. Find the corresponding file and click “Mount.”
  3. When a window asking for a password appears, enter the password you created when initially setting up the volume.

VeraCrypt will mount your encrypted disk and allow you to add all your data to the drive. Unmount the drive after you’ve finished working with these files and want to hide them away.

How to lock files

The below-given steps will help you lock the files on your Linux desktop.

1. File encryption using Zip

It is a pre-installed CLI utility that helps in decrypting files on Linux. By following the steps provided, you can use Zip to password-protect your files.

  • Firstly, you’ll need to open the terminal to use the cd and Is commands to open the directory.
  • Enter this command: zip –password wanted_password filename1 filename2 (replace ‘wanted_password‘ with the password you want to set and ‘‘ with the file name you wish to have in the final archive)

When you need to open these files, simply unzip the archive folder. It will ask for a password, enter it and access the file.

2. Encryption using GnuPG

GnuPG is also a free Linux program that comes pre-installed on almost every distro and is user-friendly.

Here’s how you can use GnuPG to encrypt a file –

  • Access the terminal on your desktop.
  • Makes use of the cd command and Is command to open the directory from which you want to choose a file for encryption.
  • Once the directory is opened, enter this command: gpg -c filename
  • Lastly, you’ll be asked to enter a passphrase. Enter a strong password there.

GPG will generate an encrypted file in your existing working directory. To read it, you’ll need to decrypt it first. Run the following command and, when asked for a password, type the one used during the encryption of the file and click Enter: gpg filename.gpg

After this step, your file will be decrypted in the same directory, and you’ll be able to access it.


Many reasons might motivate you to protect folders or files you have on your Linux computer. Some might relate to snoopy family members or roommates that might look at your files without asking. Additionally, you might share your computer with another person, which could also push for a way to keep things separate. Furthermore, other motives for securing files might include protection against hackers that could gain access to your operating system.

Whichever reason is your stimulus; we hope these instructions help you achieve the security level you want!

Related posts

Leave a Reply

Required fields are marked *

Copyright © 2022 All rights reserved.