This guide will show you how to securely delete data in Linux so that the files are incredibly difficult to recover.
When people throw away important documents they usually use a shredder to make sure that these documents can’t be read by unauthorized people. Similarly companies run a shredding process on computers before either discarding or donating them. This is a good practice even for individuals. You don’t want someone getting hold of your personal data such as photographs, emails, bank documents, etc. Let’s look at how you too can securely delete data from a Linux hard drive before you sell it, give it away or recycle it.
We’ll use the Linux program shred for this. shred is a tool that usually ships out of the box with most Linux distributions. If you don’t have it installed just use your Linux distribution’s package manager to to get it. Shred is a pretty useful tool. It can be used to securely delete individual files or even complete drives. Note that if you are trying to shred the hard drive on which your operating system is running you will need to use a “Live CD distribution” such as the Ubuntu Live CD.
Say you have a hard drive located at /dev/hda on your Linux computer and you want to shred it’s contents completely run the following command:
# shred -fzv -n 100 /dev/hda
Here’s the breakup of the command shown above. We’re asking the shred command to forcefully (-f) overwrite the disk with zeros (-z) and display the output in a verbose (-v) manner. We’re asking shred to overwrite the disk with the these zeros a hundred times (-n 100) over.
Checkout the shred command’s man page for more information on how to use it. There are a few other options explained in the man page that you might find useful.