The operating system does not completely erase a file when the file is detected. The file could be recovered by third party forensic tools. But we can use the shred command to overwrite a file, to make it almost impossible for it to be recovered. The file is overwritten three times, by default, which can be changed by the -n option.
$shred –n 5 trial.txt
The above command will overwrite the file trial.txt five times.
The –u option can be used to remove a file after overwriting.
$shred -u trial.txt
The shred tool may not work in journaling file systems and RAID file systems.
Even the’srm’(secure remove) and ‘wipe’ utilities can be used to securely remove a file, though they are not installed by default in most Linux system.