Securely remove files on Linux

When you delete a file with rm it's still possible to recover the file or parts of it. Use shred to overwrite the content of a file and delete it afterwards.

shred -u $file

Be aware that this is not sufficient for flash memory, like SSDs or USB pen drives. The write will possibly target another memory area than where the file was located previously. Prefer disk encryption whenever possible.

Erasing directories

To erase complete directory structures, using shred is cumbersome. Use wipe instead:

wipe -r directory

The above warning for flash drives applies for wipe as well.

Thomas Eisenbarth About 13 years ago