DEV Community

Cover image for The Confidential Data You Recently Deleted Is Still There and It Is at Risk of Being Leaked
JF Melo
JF Melo

Posted on • Edited on

The Confidential Data You Recently Deleted Is Still There and It Is at Risk of Being Leaked

Regular file deletion is not enough to protect confidential information.

Hitting the "delete" button does not permanently remove the data from your hard drive. Instead, the operating system only removes the reference to its location and marks the space as available for reuse. The data remains on the disk until it is overwritten by new data. This means that with the right tool, someone could easily recover your supposedly "deleted" file and access sensitive information.

What can you do to delete confidential files and make them unrecoverable?

Use a secure file deletion tool to permanently delete your confidential files.

There are several tools available to erase a file and make it unrecoverable. These tools work by overwriting the file many times with random data until there are no more residues of the original data.

Shredding files on Linux

Linux distributions have the shred command. This command overwrites the file repeatedly, making it harder for even very expensive hardware to recover it. By default, it overwrites a file 3 times, although you can specify the argument -n followed by the number of overwrites you want.

Example of a confidential file containing a database user and password

Using the .env file above as an example of a confidential file, let's overwrite it with random data 3 times, by executing the following command:

shred .env
Enter fullscreen mode Exit fullscreen mode

It is worth noting that the command above does not remove the file after overwriting it. If you also want to remove the file, you need to add the argument -u.

Example of a confidential file after it is overwritten by the shred command

In the picture above you can see how the file looks after it is overwritten by the shred command.

Popular shred tools for Mac

Popular shred tools for Windows


Conclusion

Whether it be for personal privacy or for compliance with data privacy regulations, it is essential to be proactive when it comes to protecting sensitive information. Research and find a secure file deletion tool that works for you and your needs to protect yourself and your data.


Photo by Frank R on Unsplash

Top comments (0)