How to protect and secure your data in Linux

Linux is a multiuser operating system so that you may want to keep your some data, files, programs or directories private i.e non accessible by other users. Linux allows users to protect their data from the other users with the feature called file permission and password protection. We have already discussed how to control the level of security by limiting the users to read, write or execute a file. Also, you can protect your data or files with the password. In this tutorial, I am going to show you how to implement effective file protective scheme in Linux.

File permission:

There may be various owners and the users who will use the file that will belong to the group. As one user, you mayn’t want other users to see your data. In other words you want your data or file non-accessible or protected. Chmod command sets the permission to the file limiting it’s user view. There’s a detail tutorial on the file permission, Chmod Linux and Unix Command.

Password Protection:

We will use gpg utility to password protect  the files and directories. Gpg encrypt and password protect the files. Initially gpg was only available to operate from command line. But, now you can also use GUI of gpg.

Command line:

Make sure gpg is installed in your system by typing the following command:

whereis gpg

If you get output like:

gpg: /bin/gpg /usr/bin/gpg /usr/share/man/man1/gpg.1.gz

then gpg is installed in your system. If it’s not available, install it! Gpg is available in repository of every Linux system by default.

Zip the file:

It’s always best practice to compress files into zip format or any other format to implement encryption and password mode. However, it’s not mandatory.

Type the following command to password protect file:

gpg -c file_name

I have a file named “hello.zip” in my home directory to which I want to add password. I would type:

gpg -c hello.zip

gpg file encryption

As you can see, you would be asked to enter passphrase which is going to be the password. You have to enter passphrase twice. Gpg utility creates a password encrypted file with extension .gpg which means the original file is not deleted. You can delete the original file and keep the encrypted one. Don’t worry your file is there but no one can crack it, even the admin cannot open your file without knowing the password.

To remove password:

You cannot view the file or data without removing the password. To remove the password type:

gpg file_name.gpg

remove password

GUI:

Download the Gpg GUI version.

Install  gtk+-2.0 by typing the following command:

sudo yum install  gtk2-devel

Extract downloaded Gpg Gui Version:

tar -xvzf gpg_gui-current.tar.gz

Go to the extracted directory and install:

cd gpg_gui-current

make

make install

GUI version of Gpg is now successfully installed. Open from terminal by typing:

gpg_gui

Select the file, give the password and hit Encrypt.

graphical GPG

Select the file, give password and hit Decrypt to Decrypt.

0saves
Posted in Linux | Tagged , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>