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

Commands using shred from sorted by
Terminal - Commands using shred - 11 results
shred -v filename
sudo shred -vz -n 0 /dev/sdb
shred --iterations=N /dev/sdaX
2012-01-23 20:40:36
User: bibe
Functions: shred
0

Instead of zeroing the filesystem, this command overwrites N times (default is 3) the disk content, making data recovery much harder.

The command accepts many more options

gpg -e --default-recipient-self <SENSITIVE_FILE> && shred -zu "$_"
2011-07-24 05:51:47
User: h3xx
Functions: gpg shred
Tags: GPG shred
0

Make sure the file contents can't be retrieved if anyone gets ahold of your physical hard drive.

With hard drive partition:

gpg --default-recipient-self -o /path/to/encrypted_backup.gpg -e /dev/sdb1 && shred -z /dev/sdb1

WARNING/disclaimer: Be sure you... F&%k it--just don't try this.

function rrm(){ for i in $*; do; if [ -f $i ]; then; echo "rrm - Processing $i"; shred --force --remove --zero --verbose $i; else; echo "Can't process $i"; type=$(stat "$1" -c %F); echo "File $i is $type"; fi; done;}
2010-06-10 22:40:27
User: thelan
Functions: echo shred stat
Tags: shred
1

This command remove a file from your filesystem like the normal rm command

but instead of deleting only the inode information this also delete the data that was stored on blocks

/!\ warning this may be long for large files

shred -u -z -n 17 rubricasegreta.txt
2010-01-31 15:24:54
User: 0disse0
Functions: shred
6

Instead, install apt-get install secure-delete and you can use:

-- srm to delete file and directory on hard disk

-- smem to delete file in RAM

-- sfill to delete "free space" on hard disk

-- sswap to delete all data from swap

# cd $partition; dd if=/dev/zero of=ShredUnusedBlocks bs=512M; shred -vzu ShredUnusedBlocks
2009-06-21 14:17:22
User: mpb
Functions: cd dd shred
8

This command securely erases all the unused blocks on a partition.

The unused blocks are the "free space" on the partition.

Some of these blocks will contain data from previously deleted files.

You might want to use this if you are given access to an old computer and you do not know its provenance.

The command could be used while booted from a LiveCD to clear freespace space on old HD.

On modern Linux LiveCDs, the "ntfs-3g" system provides ReadWrite access to NTFS partitions thus enabling this method to also be used on Wind'ohs drives.

NB depending on the size of the partition, this command could take a while to complete.

shred -vzu /tmp/junk-file-to-be-shredded
shred -n33 -zx file; rm file
2009-05-08 19:15:41
User: copremesis
Functions: rm shred
1

remove file that has sensitive info safely. Overwrites it 33 times with zeros

sudo shred -zn10 /dev/sda
2009-04-30 13:02:43
User: dcabanis
Functions: shred sudo
-2

Shred can be used to shred a given partition or an complete disk. This should insure that not data is left on your disk

shred targetfile
2009-04-28 19:57:43
User: sud0er
Functions: shred
5

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