How to Permanently Delete Files On Windows & LinuxCategory: misc
A 7 Minute Read
07 Jan 2014
We've all woken up in the morning and gone to our computer to find a folder created last night after a few drinks, containing 17 years of our tax documents, 47 naked photos, a government leak we were going to send to Julian Assange, and 672 emails to a prostitute named Lynda in New York. Well, maybe not, nevertheless secure file deletion is incredibly important. Whether you are trying to delete financial documents, embarrassing photos, or anything else that you don't want someone to find out about, simply hitting the "delete" button doesn't cut it. These days much of our data is stored on laptops, USB flash drives, or portable hard drives, all of which are easily stolen. In fact, if you ever decide to sell any of these devices without properly deleting your files, the buyer could recover the files you thought you had deleted and read them. Secure file deletion goes far beyond a simple delete button, and this tutorial will explain it all!
Why Isn't Just Pressing "Delete" Enough?
Most modern operating systems don't actually "delete" files. Instead, they mark them as deleted. This is because of how modern storage works. When you create a file the operating system creates a 'pointer' to that file so that it can be accessed faster. Similarly, when you delete a file, the operating system merely removes that pointer. This is because of the massive speed reduction that would occur if it were to delete the file itself. To actually delete a file it needs to be overwritten. Think of how long it takes to transfer a large file, such as a movie, from one device to another. The speed it takes to do this is limited usually by the "write speed" of your hard drive. Deleting the file would take the same amount of time, as real file deletion is merely a function of writing over top of the deleted file and is limited by the same write speed. This is why Windows, Linux, and Mac operating systems usually just delete the pointer instead of the file itself.
Simply deleting the pointer, however, leaves the file on the hard disk until it is overwritten. This means that you, or someone else with access to your computer, can go back and recover that file. Of course, that is a security disaster if you just had your device full of what you thought were 'deleted' financial documents stolen. It's like taking the name off the folder in a file cabinet, instead of burning the file itself. Of course, there is a solution for this: overwriting.
Secure File Deletion, Myths and Reality
Overwriting a file with random data is what is done to actually delete a file. This is the method used by most 'file shredders', which often do this anywhere from 1, to 35+ times. It's the same idea as using a permanent marker to black out text on a piece of paper; the more times you write over it, the harder it is to read. This idea exploded in 1996 when a man named Peter Gutmann presented a paper showing how simply overwriting something once isn't secure, and instead proposed a method which overwrites files 35 times. This has become the standard of many secure file deletion programs. In fact, you'll probably notice it with the programs I'm going to tell you about later. With modern hard drives, however, its necessity is a myth.
When Gutmann presented the paper, his ideas were based more on theory than on practice. Furthermore, they were based on previous hard drive technology. Recent research, however, has shown that Gutmann's idea that a file needs to be overwritten 35 times to be actually secure (a mentality that has also been accepted by the security industry) doesn't apply anymore. At the Fourth International Conference on Information Systems Security, researchers showed that overwriting a file even a few times with current hard drives caused the file to be unrecoverable. The paper can be found here assuming you have access to the library. Another paper from Stony Brook University cites government deletion standards for top secret documents calling for no more than three overwrites. So to save your hard drive some unneeded work, and to save yourself some time, when using the programs I'm about to describe, don't bother with more than three overwrites.
How to Securely Delete Files on Windows
Windows users have a plethora of options to securely delete files. I'm going to focus on two of them today. The first option is a simple tool called Moo0 File Shredder ; an exceptionally strange name for a tool which seems to just work. There are many other programs with extensive feature-sets, however I frequently find myself just going back to Moo0 because of its straight up utilitarian simplicity. It gives you four options: Shred Once, Extra Careful, Into Ashes, and Vaporize. Usually Shred Once should be sufficient. If you have a document that you really want gone, however, go with Extra Careful (or Vaporize if you want to be a paranoid android and have the time, but it's mostly unnecessary). To securely delete a file with Moo0, just drag it from your file explorer to the "Drop Box" on the left. It's that simple.
The next Windows option is CCleaner . Ccleaner doesn't just wipe one file specifically, instead it can be used to either wipe all of your temporary files, such as cookies and browser history, or to wipe your "free space". The first option causes the 'Cleaner' tool (a tool you may already use) to overwrite all the files that it cleans instead of just deleting them. To enable this just go into the options menu, then go to settings and select "Secure File Deletion". Again, a one or three pass overwrite is probably sufficient. The second feature of Ccleaner is a bit more interesting. What it does is take all the free space on your drive and overwrite it. This means that all the files which you may have simply marked as deleted in the past will be removed. This is a good option to clean up your computer after a history of insecure use. To do this, go into the tools menu, and go down to the drive wiper. Here, select "free space only", and then select the drive you wish to clean up. Then just hit 'wipe' and Ccleaner will do its work.
How to Securely Delete Files on Linux
Linux users also have multiple ways to securely delete files. The first option is to simply use the command "shred". For example, "shred -fnvz 5 nakedphoto.png". What this will do is securely delete the file, overwriting it five times. The 'f' option will change the permissions of the file if necessary to delete it. The 'n' option allows the user to specify the number of times they want to shred the file. Lastly, the 'z' option will add a final overwrite of zeros, which hides the fact that the file was shredded.
Another option that Linux users have is the "secure-delete" package. To get this package in a Debian system, simply type "sudo apt-get install secure-delete". The package contains multiple tools to securely delete different areas of your system, however today we'll focus on two of them: srm and sfill. The 'srm' tool is simply a tool which works like the 'shred' command. By default srm will overwrite with 35+ passes using the Gutmann method, which we learned earlier was unnecessary. An option that you can add to the srm command is '-l'. The '-l' option lessens the security, doing only two passes instead. Another one of the features of srm is the '-r' option (recursive), which allows the deletion of entire folders, making it very similar to the good ol' 'rm' command. To find out more about the options available in srm, just type "srm --help".
The secure-delete package also contains 'sfill'. The sfill command is similar to Ccleaner's "wipe free space" option. It also works similarly to srm in terms of its options. It will use the Gutmann method by default, but again, this is unnecessary and can take a HUGE amount of time to do, so I'd suggest tapping a '-l' in there. What sfill will do is create a file on the disk that you choose, which will grow until it consumes all the free space on the disk, effectively wiping it. Once again, to learn about all the options of sfill just type "sfill --help".
Wiping an Entire Disk
Perhaps you plan on selling your computer, or getting rid of it. An important step before doing this is to securely delete all the data on the hard drives. There are a few tools to do this. The easiest and most securely is probably DBAN (Darik's Boot and Nuke). This, of course, is a whole 'nother beast. So instead of doubling the length of this tutorial, I'll refer you to The University College Dublin's guide on how to do this.
An alternative method to wiping an entire hard drive is to use CCleaner's drive wipe option. This feature is in the same menu as the one where you used it to wipe the free space, however instead of wiping the free space, select the option to wipe an entire disk. The caveat of this is that you can only wipe a drive that the operating system isn't running on (in other words you can't wipe the C drive, but you can wipe the D).
A Final Note: SSDs Aren't Great For Security
While all these tools are great on traditional hard drives, modern SSDs pose a problem. SSDs work quite a bit differently from hard drives, and without explaining the entire functioning of an SSD, I'll say this: securely deleting files on a SSD requires the deletion of all the free space on the drive.In other words, don't use solid state drives to store sensitive information if you have a hard drive available. If you want to learn more as to why, I'd give these links a quick visit:
Disclaimer: Please exercise caution when deleting files. Any file you delete using the tools explained in this tutorial will render it unrecoverable. Also, while these methods are extremely effective, they cannot be 'guaranteed' to work 100% of the time.