How to Securely Delete Data From a Hard Disk in Linux

This guide will show you how to securely delete data in Linux so that the files are incredibly difficult to recover.

Please note: This guide was initially published back in 2009 – long before SSD drives. You should not use the shred command in Linux if the machine is using an SSD drive. Not only will it not work, it can shorten the lifespan of the drive. If you’re using an SSD drive, I would strongly suggest you investigate the blkdiscard command instead.

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.


If this article helped you, I'd be grateful if you could share it on your preferred social network - it helps me a lot. If you're feeling particularly generous, you could buy me a coffee and I'd be super grateful :)

buy a coffee for simplehelp.net


Home » Linux » How to Securely Delete Data From a Hard Disk in Linux

Leave a Comment

Your email address will not be published.