How to Password-Protect Files and Folders on Linux
Whether you want to share a file online, store it in the cloud, carry it on a thumb drive, or add it to your archive, password-protecting it is the best approach to secure its content and prevent unauthorized access.
The same holds true for folders too. Therefore, it’s crucial to encrypt them as well. On Linux, you have several ways to password-protect files and folders. Most of these methods use encryption, which offers additional protection than others.

Here’s a look at all the different methods it’s possible to use to password-protect files and folders on Linux.
How to Password-Protect Files on Linux
Linux has multiple utilities to help you password-protect/encrypt files on your computer. Listed below are the methods you can use to do this.
Method 1: Encrypt a File Using GnuPG
GnuPG is a free Linux program that supports multiple encryption standards for file encryption. It comes pre-installed on most Linux distros and is pretty easy to use.
GnuPG is accessible via the CLI. Here’s how you can use it to encrypt a file :

GnuPG will now create an encrypted file (with.gpgextension) in your current working directory. To access it, you’ll need to decrypt it. For this, run the following command, and when prompted for a password, enter the one you used to encrypt the file and hitEnter:
GnuPG will return a decrypted version of the file in your current working directory.

If you’d like to use any other encryption algorithm, first, check the supported ones by running:
And then, specify the desired algorithm in the command like this:

Method 2: Encrypt a File Using Zip
Zip is another CLI utility that lets you password-protect files on Linux. It comes pre-installed onall major Linux distrosand is ideal for archiving or zipping multiple files into one encrypted archive.
Follow these steps to use Zip for password-protecting a file:

Now, when you want to access these files, unzip the archive and enter your password. Or, to do it via the terminal, run:
Zip will now ask you for a password. Enter the password you set at the time of encryption and hitEnterto decrypt the file.
Method 3: Encrypt a File Using mcrypt
mcrypt is a crypt replacement that makes encrypting files on Linux easy. It supports various encryption standards and you have the option to specify the encryption algorithm based on your preference.
Here are the steps to encrypt a file using mcrypt:
mcrypt will now encrypt your file and save it with the “.nc” extension. If you wish to open this file, you’ll need to decrypt it. To do this, run:
And then, enter the decryption passphrase.
How to Password-Protect Folders on Linux
Similar to how you password-protected files on Linux, password-protecting folders is also straightforward. Below is a list of all the methods you can use and the steps to use them.
Method 1: Encrypt a Folder Using GNOME EncFS Manager
GNOME EncFS Manager is a mounting utility that lets you encrypt folders on Linux with ease. It’s supported by most Linux distros and has a neat GUI, which makes it easy to use.
Here are the steps to use GNOME EncFS Manager for encrypting a folder on Linux:
GNOME EncFS Manager will now create an encrypted folder (also called stash) and mount it to your selected destination directory. Double-click on this mounted drive to access the contents of the folder inside. To unmount it, check off the checkbox beside it. Or right-click on the stash and selectUnmount.
Now, when you want to mount it again, just tick the checkbox. GNOME EncFS Manager will ask you for your password. Enter the password, and you should now be able to access all its contents.
Method 2: Encrypt a Folder Using VeraCrypt
VeraCryptis a free and open-source disk encryption tool. It’s available on all major operating systems, and you can use it to create an encrypted directory on Linux where you can store files and folders securely.
First, download VeraCrypt on your computer from the link below and install it.
Download:VeraCrypt
Next, launch it from the applications menu and follow these instructions:
Now, you need to mount this encrypted volume. To do this, go back to the VeraCrypt main window and click onSelect File under Volume. Choose the file and click onMount. When prompted for a password, enter the password you set at the time of volume creation.
VeraCrypt will now mount your encrypted drive, and subsequently, you can add all your personal data (files or folders) to this drive. When you’re finished working with these files and wish to lock and hide them away, unmount the drive.
Secure Personal Data on Linux Effectively
Depending on your preference, you can pick any method and tool listed above to password-protect your files and folders on Linux and prevent unauthorized access. If you share your computer with someone, this can be a really effective way to ensure no one besides you can access your personal data.
Suspect that your computer isn’t how you left it? Think someone is checking on your computer? Learn how to tell if someone was snooping on your PC!
OneDrive is one of the best, but it has a catch.
Taming data is easier than it looks.
Goodbye sending links via other apps.
Lose your laptop without this feature, and you’ll wish you had turned it on.
Every squeak is your PC’s way of crying for help.