What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Securely destroy data (including whole hard disks)

Terminal - Securely destroy data (including whole hard disks)
shred targetfile
2009-04-28 19:57:43
User: sud0er
Functions: shred
Securely destroy data (including whole hard disks)

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 :)


There are 29 alternatives - vote for the best!

Terminal - Alternatives

Know a better way?

If you can do better, submit your command here.

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?

Comment by kaedenn 369 weeks and 1 day ago

Shred works well. You can't run it from the partition being wiped. It is slow, though.

Comment by fritz_monroe 369 weeks and 1 day 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.

Comment by sud0er 369 weeks and 1 day 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.

Comment by Resolution 369 weeks 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?

Comment by urpwnd 368 weeks and 3 days ago

Your point of view

You must be signed in to comment.