How to safely remove a file that contains sensitive data in Linux
In Category Command Line
Typically a file removal operation, in Linux or any other operating system, doesn’t actually erase all contents of the file. Though the file is logically deleted and doesn’t appear to the be present, its contents still present in the hard drive. Any raw disk reading software or a data recovery tools can detect such contents to gain access to sensitive information such as passwords, credit card numbers etc.
Let us assume that you have stored your passwords and credit card numbers in a plain text file, even once temporarily. It is always wise to overwrite the file contents many a times before removing the file so that it becomes harder for raw disk software or any expensive hardware prober to recover any data.
Linux provides a command “shred” that can be used to overwrite a specific file repeatedly and optionally delete it.
shred mypassword.txt rm password.txt
You can use “-u” option provided by shred to do the job with a single command.
shred -u mypassword.txt
Recent Comments