You can use a similar technique to wipe data from a file before deleting it, making it almost impossible to recover data from the deleted file. You might want to wipe a file for security reasons.
In the following example, ls shows the size of the file named secret. Using a block size of 1 and a count corresponding to the number of bytes in secret, dd wipes the file. The conv=notrunc argument ensures that dd writes over the data in the file and not another (erroneous) place on the disk.
$ ls -l secretfile
-rw-r--r-- 1 sam sam 5733 2007-05-31 17:43 secretfile
$ dd if=/dev/urandom of=secret bs=1 count=5733 conv=notrunc
5733+0 records in
5733+0 records out
5733 bytes (5.7 kB) copied, 0.0358146 seconds, 160 kB/s
$ rm secretfile
For added security, run sync to flush the disk buffers after running dd, and repeat the two commands several times before deleting the file. See wipe.sourceforge.net for more information about wiping files
No comments:
Post a Comment