Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

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

Alternatives

There are 6 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 286 weeks and 3 days ago

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

Comment by fritz_monroe 286 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.

Comment by sud0er 286 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.

Comment by Resolution 286 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.

http://16systems.com/zero.php

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 285 weeks and 5 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts