Home > bash, security > securely delete (wipe) a file/partition

securely delete (wipe) a file/partition


I had a USB stick that I wanted to clean, i.e. even if I lose it, I don’t want anyone to be able to recover the data on it.


Removing a file with rm or formatting a partition (with gparted for instance) is not enough. There are tools that can restore deleted files. A better way is to overwrite a file/partition repeatedly with random garbage (wipe). And there is still the most secure way: smash your drive with a hammer and pour acid on it :)


Shred can wipe a file or an entire partition. If you shred a partition, all data on it will be lost. If you only want to wipe the free space, you’ll need another tool. Here is how I wiped my USB stick:

# figure out the device reference of the partition:
df -h
# then wipe it:
sudo shred -n 5 -v /dev/XXX

Where -n 5 means we want to overwrite the paprtition 5 times; -v means verbosity; and /dev/XXX is the device reference of the partition.

Credits: http://www.linux.com/archive/feature/52258.


  • secure-delete tools (sudo apt-get install secure-delete); more info here
  • wipe (sudo apt-get install wipe); more info here
  • dban; more info here

The toolset secure-delete comes with four commands:

  1. srm (remove files/directories)
  2. sdmem (wipe memory)
  3. sfill (wipe free space)
  4. sswap (wipe swap partition)
Categories: bash, security Tags: , ,
  1. October 29, 2012 at 10:22

    i finally found some simple tool to wipe only a partition (fill it with zero).

  1. August 3, 2011 at 10:57

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: