Securely destroy data (including whole hard disks)

shred targetfile
GNU shred is provided by the coreutils package on most Linux distribution (meaning, you probably have it installed already), and is capable of wiping a device to DoD standards. You can give shred any file to destroy, be it your shell history or a block device file (/dev/hdX, for IDE hard drive X, for example). Shred will overwrite the target 25 times by default, but 3 is enough to prevent most recovery, and 7 passes is enough for the US Department of Defense. Use the -n flag to specify the number of passes, and man shred for even more secure erasing fun. Note that shredding your shell history may not be terribly effective on devices with journaling filesystems, RAID copies or snapshot copies, but if you're wiping a single disk, none of that is a concern. Also, it takes quite a while :)

By: sud0er
2009-04-28 19:57:43

What Others Think

I still use dd a number of times. But if you want to destroy stuff, why not take the medium to your local drill press and let metal shavings fly?
kaedenn · 664 weeks and 3 days ago
Shred works well. You can't run it from the partition being wiped. It is slow, though.
fritz_monroe · 664 weeks and 3 days ago
Thanks for pointing that out, fritz. Yeah, I was worried about people thinking this was equivalent to one of the "sudo rm -rf /" malicious posts, when its really about erasing data securely. Shred is smart enough not to roast /dev/hda when you're running off of it. Kaedenn, in my tests, shred is slightly faster (and easier) than a comparable set of dd's. I didn't test the drill press, but I'd expect that would be quite a bit faster. Harder to re-purpose your old drives afterward, tho.
sud0er · 664 weeks and 3 days ago
For regular files, BSD includes the -P option with the "rm" utility: -P Overwrite regular files before deleting them. Files are over- written three times, first with the byte pattern 0xff, then 0x00, and then 0xff again, before they are deleted. Files with multi- ple links will be unlinked but not overwritten.
Resolution · 664 weeks and 3 days ago
why not just use dd. dd if=/dev/zero of=/dev/ doing this multiple times isn't needed. read up, and stop wasting time overwriting multiple times or destroying perfectly good drives. if skilled scientists with electron microscopes can't recover any usable data from a single pass dd wipe, who do you think can?
urpwnd · 663 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: