Commands using shred (11)

  • 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. Show Sample Output

    # cd $partition; dd if=/dev/zero of=ShredUnusedBlocks bs=512M; shred -vzu ShredUnusedBlocks
    mpb · 2009-06-21 14:17:22 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

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

  • 6
    sudo shred -vz -n 0 /dev/sdb
    bugmenot · 2012-08-06 22:37:44 0
  • 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 :)

    shred targetfile
    sud0er · 2009-04-28 19:57:43 5
  • remove file that has sensitive info safely. Overwrites it 33 times with zeros

    shred -n33 -zx file; rm file
    copremesis · 2009-05-08 19:15:41 3
  • 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 Show Sample Output

    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;}
    thelan · 2010-06-10 22:40:27 0

  • 0
    shred -vzu /tmp/junk-file-to-be-shredded
    mpb · 2009-06-18 12:00:19 2
  • 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.

    gpg -e --default-recipient-self <SENSITIVE_FILE> && shred -zu "$_"
    h3xx · 2011-07-24 05:51:47 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

    shred --iterations=N /dev/sdaX
    bibe · 2012-01-23 20:40:36 0
  • Shred can be used to shred a given partition or an complete disk. This should insure that not data is left on your disk

    sudo shred -zn10 /dev/sda
    dcabanis · 2009-04-30 13:02:43 3

  • -5
    shred -v filename
    techie · 2013-05-07 14:58:17 0

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

Check These Out

Matrix Style
Solves "tr" issues with non C-locales under BSD-like systems (like OS X)

Create a tar of directory structure only
The original suggestion did not work for me, when operating on folders located on an external mount (ie other than the root device) in Ubuntu. A variation using xargs does the trick.

Get Nyan'd
Get nyan'd

check open ports (both ipv4 and ipv6)
While `lsof` will work, why not use the tool designed explicitly for this job? (If not run as root, you will only see the names of PID you own)

Better git diff, word delimited and colorized
I've been using colordiff for years. wdiff is the new fav, except its colors. Word delimited diffs are more interleaved, easing the chore of associating big blocks of changes.

copy last command to clipboard
Copy the last command to clipboard (os x)

Number of open connections per ip.
Here is a command line to run on your server if you think your server is under attack. It prints our a list of open connections to your server and sorts them by amount. BSD Version: $ netstat -na |awk '{print $5}' |cut -d "." -f1,2,3,4 |sort |uniq -c |sort -nr

search string in _all_ revisions

Check SSH public and private keys matching
Tested in bash4

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

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: