How to encrypt and decrypt the file in Linux

by admin May 10, 2017 at 11:28 am

Sometimes you may need to send a important files as a attachment thru emails. Better if the files was sent in encryption mode then unauthorized person can’t misuse the file.

Now we will see here how to encrypt and decrypt the file in Linux.

To encrypt a file :

File can be encrypted using gpg command as shown below

#gpg -c test.txt>             

once you issued the command then you will get a popup window to enter the password twice.

3b474cc54825dd32

Now the new encrypted file test.txt.gpg is created in the same directory and nobody can read the content in this file without decrypt the file and this can be done only who knows the password.

To make sure the file test.txt.gpg is decrypted, Run cat test.txt.gpg

Let see how to decrypt the test.txt.gpg to read the content

To Decrypt the file, just run gpg command without any option

#gpg test.txt.gpg

Now you will be prompted to enter the password, enter the password which you have set while encrypt the file.

3b474cc54825dd32

Once password authentication successful then file will be decrypted and content is readeable.

I hope you like this article, If yes then Pls. share this article with your friends.

Add Comment