Wipe entire hard drives
The primary usage of the
shred command is to wipe entire partition by overwriting the content. For example, to wipe
shred -vfz -n 10 /dev/sda5
-v: show progress
-f: change permissions to allow writing if necessary
-z: add a final overwrite with zeros to hide shredding
-n: overwrite N times instead of the default three time
Here we will overwrite
/dev/sda5 ten times, enough to ensure that data can’t be retrieve without very special and complicated method.
Shred individual files
shred can also be use to overwrite and delete a given file, but it maybe not so efficient in that case. The man page warm you about:
CAUTION: Note that shred relies on a very important assumption: that the file system overwrites data in place. This is the traditional way to do things, but many modern file system designs do not satisfy this assumption.
It’s hard to evaluate if recovery of a “shredded” file could be possible, as it depend on the filesystem (and the mount options for ext3/4) and how data is ordered on the device. But keep this limitations in mind. For the command simply do:
shred -u foobar.txt
shred overwrites the file 25 times. You can customize this value using the