How to encrypt a file in Linux

File Encryption in Linux,

           In a Digital world most of all out data’s are out of threat, out of all our personal details such as pass-phrase details, digital signatures are prone to a great danger.

But most of you have ever tried to encrypt your files in Linux to keep it secure. if so here come a very sample demo to encrypt and get secured.

gpg – GnuPG (Gnu Privacy Guard) is a command line tool in Linux and Unix-Operating Systems that secure communication data and data storage. It can be used to encrypt data and to create digital signatures. It includes an advanced key management facility.

here is the tutorial of step by step procedure begins

step 1

Open Terminal, In Ubuntu (Applications -> Accessories -> Terminal) or keyboard shorcut Ctrl+Alt+T

step 2

Now go to the directory in which the file you need to be encrypted is present
In my case i have in the path ->  /home/uppili/Downloads/demo
so my terminal command to change the directory is

 $ cd Downloads/demo/

then to view my files present in it

 $ ls

to encrypt the file the command is

$ gpg -c file_name

so the file named “file_name” gets encrypted

In my case

$ gpg -c invitation.jpeg


Step 3

I will now ask for a Pass-phrase, so you need to enter a pass-phrase i.e password to encrypt the file and please remember this password because only using this you can decrypt and get back the original file.

Then you need to retype the same pass-phrase again retype it in-order to provide a confirmation to encrypt the file.

Step 4

A new file with ” file_name.gpg ” will be created

In my case invitation.jpeg.gpg is created

now you can delete the original file, i.e  ”file_name “.

Step 5

Now your file is secured, and to decrypt back your file to get back the original file use this,

 $ gpg file_name.gpg

in my case

 $ gpg invitation.jpeg.gpg

This time it will prompt for the Pass-phrase which you used to encrypt this file. This is how you can Encrypt and Decrypt your files, so they are secured.


Thats it

now its time to get your hands dirty

practice makes a man perfect

lets get hand-on and try



One Reply to “How to encrypt a file in Linux”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s