Shred. Delete Files Securely.


You all have used and even over used the “rm” command in your Linux Training and Implementation.

No need to tell you, why you use rm.

But is “rm” safe in protecting your sensitive files that you want to delete and don’t want anyone to recover those files using any data recovery methods?

The answer is hmmm .. “may be” or “not”.

Now understand how “rm” works. When you issue “rm” command against some file the rm just remove the link between the name and the inode. It just free the inode. The data is very much there and can be recovered (thought not easily) using tools and apps. designed for this purpose.

So what is shred how does “shred” works?

Shred not only deletes a file, but deletes it in such a way that it cannot be recovered. Shred overwrites the file multiple times with garbage prior to deleting it, thus ensuring that if anything does get retrieved, it isn’t your top-secret data. 🙂

Here I have used shred once without any options. So can see in that it fills the file with garbage contents as expected. Now you can remove it using your friendly “rm” command.

In the second case I had used some options with shred. To let shred do all the things for me. Here:

-f => means change the file permissions to allow write, if required.
-u => means remove the file after truncating it.
-v => obviously, verbose, show me what you are doing.
-z => add zeros to hide the shred.

Here is a small illustration showing shred in action from my machine.


Shred Linux Command

Shred Linux Command