How to encrypt and decrypt a file in Linux.

There are two commands which do the encryption and decryption of file in Linux. This will be more helpful when you carry confidential data in Laptop or pendrive.

1. Mcrypt is the command for encrypt the file and mdecrypt is the command for decrypt the file.


# cat test.txt

password: test123

# mcrypt test.txt

Enter the passphrase (maximum of 512 characters)

Please use a combination of upper and lower case letters and numbers.

Enter passphrase:

Enter passphrase:

File test.txt was encrypted.

# rm test.txt

# ls -l test*

-rw——- 1 root root 125 2012-08-23 15:59

# mdecrypt

Enter passphrase:

File was decrypted.

# cat test.txt

password: test123


2. Similarly gpg is the command for encrypting and decrypting a file.

Syntax :

a. #gpg –c filename, This will create a gpg extension at the end of the file similarly like nc mentioned above in the example.

b. #gpg –d filename which will decrypt the file.


3. For Windows you can use the gpg software:-


6 Responses to How to encrypt and decrypt a file in Linux.

  1. Pete Bjorn says:

    I simply want to mention I’m new to blogs and definitely liked you’re web blog. Probably I’m planning to bookmark your site . You actually have incredible well written articles. Many thanks for revealing your blog.

  2. a linux blog says:

    I savour, result in I discovered exactly what I was looking for. You have ended my 4 day long hunt! God Bless you man. Have a great day. Bye

  3. Lyle Levans says:

    I simply want to say I am just very new to blogging and absolutely savored you’re website. Probably I’m likely to bookmark your website . You amazingly come with perfect articles and reviews. Regards for sharing your web page.

  4. I acquired this from the mail about fourteen days ago and I’ve come across a stable drop in my blood pressure since. I am additional energetic and happier. Its amazing because I started taking these caps with my new fitness plan and my route to health looks much more promising. Awesome find!

  5. Blair Gidden says:

    I really like your writing style, wonderful information, appreciate it for posting :D.

  6. Some genuinely excellent information, Glad I discovered this.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: