Deleting files is probably not something you think about on a regular basis, but you inevitably do it regularly without thinking. Files come and go, but on a dedicated server, it is sometimes important to make sure the files you have deleted are truly gone.
The “rm” command in Linux is the standard command most sysadmins use to delete files, and it works just fine. Few tasks are quicker than typing “rm -r -f” and wiping out old files you no longer need. But whenever you remove a file with “rm”, there are traces left behind. In many cases, this is a good thing because it means that you might be able to recover the file. In other situations, however, you want to make sure that file is truly gone.
Shred is a simple command that works much like an office shredder, making sure any documents you discard are thinly sliced and difficult to piece back together. Shred will overwrite a file with nonsense before deleting it, making sure all trace of it is erased. It overwrites the file 25 times and then renames it 11 times before finally deleting it. This ensures no one can trace the file back to its origin and resurrect it.
To shred a file, you can simply type it from the shell command line:
To specify the number of iterations for shredding, use the “-n” option:
shred -n 40 filename.html
In the example, shred will rewrite gibberish to the file 40 times before deleting it. For more information about shred, type “man shred” from the command line or read the manual file online.