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


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


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

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


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


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


    1
    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 7

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


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


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


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

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

What's this?

commandlinefu.com 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

Generate a Random MAC address
Use the following variation for FreeBSD: $ openssl rand 6 | xxd -p | sed 's/\(..\)/\1:/g; s/:$//'

Delete leading whitespace from the start of each line

Rename all images in current directory to filename based on year, month, day and time based on exif information

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Password Generation
Produces secure passwords that satisfy most rules for secure passwords and can be customized for correct output as needed. See "man pwgen" for details.

clear current line

Print out a man page
man -t manpagename gives a postscript version of said man page. You then pipe it to ls, and assuming you have cups set up, it prints in your default printer.

Print nic name of current connection

Netstat Connection Check
This command does a tally of concurrent active connections from single IPs and prints out those IPs that have the most active concurrent connections. VERY useful in determining the source of a DoS or DDoS attack.

Find and copy scattered mp3 files into one directory
No problem with word splitting. That should works on many Unix likes.


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: