I was following the advice on this site: http://www.techrepublic.com/article/how-to-easily-encryptdecrypt-a-file-in-linux-with-gpg/

I ran this command: gpg -c test.txt.

But then it created a separate file called test.txt.gpg and it left the original file. I want to encrypt a certain file so that it can't be accessed with a live CD. How can I password protect the original file?

I am using ubuntu and don't want to download a special program.


Well, that's how symmetric encryption with gpg works. You can use the -o option to specify an output. If you want to delete the source file, after successful encryption, you can use something like this:

gpg -c file && rm -rf file

This way you will have encrypted file only. Also, have a look at the shred command, it's quite handy when it comes to deleting sensitive data.

gpg -c file && shred -u file
  • Good idea. So something like this would work well? gpg -c [file name] && shred [file name] – Lumo5 Feb 7 '17 at 14:10
  • 1
    yes, but please test first on non-important files. Also, use shred with -u, as it will 1st overwrite the file contents, and then delete it. If you don't use -u it will only overwrite the file. – 13dimitar Feb 7 '17 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.