Best Ways To Password Protect Files In Linux


Linux distros are considered as the best operating systems in terms of security. But if you still want to password protect files and folder in Linux, then there are a couple of easy ways.

So, why exactly would one need to set password to files and folders in Linux? Well, that is non of our business to know it. But we would surely like to help you securing you files Linux by setting password on it.

Best Ways To Password Protect Files In Linux

Method 1 To Password Protect Files In Linux

There is a package called gpg installed on your Linux using which you can set password to files. But first, you need to ensure that you have this package installed. To do that, hit the below command:

# whereis gpg

When you fire this command, it would give you the location of the package. And it implies that you have this package installed. So, you can go ahead. And if it isn’t installed, then you can try out the second method.

Suppose that you want to password protect a file name, dwarka.zip. All you need to hit is the below command:

# gpg –c dwarka.zip

When you fire this command, it would ask you to enter the password twice. When its done, you can find that a new encrypted file is created namely, dwarka.zip.gpg. And in order to read this encrypted file, you need to enter the password that you have entered while creating it.

So, if you are wondering how to read it, then hit the below command:

# gpg dwarka.zip.gpg

This would prompt you to enter the password and this will transform your file back to the original format.

Method 2 To Password Protect Files In Linux

This method can be used if you not have gpg package installed. You can make use of its zip utility. Let me demonstrate you using the example of same file. To password protect a folder, make sure first you zip it.

And to zip it, fire the below command:

# zip –e –r dwarka dwarka

This would first prompt you to enter a password. And once it is done, it will keep the original file and also create a password protected zip file. If you want, you can delete the original file. And to use the zipped file, you need to hit the below command:

# unzip dwarka.zip

These are the two best methods to password protect files in Linux.

Filed under: Linux
Tags: ,
May 10, 2011 by: Prasanth Chandra

Comments

Leave a Reply