How To Securely Delete & Wipe Data [Linux]
Making sure you have adequate security measures in place while working on your computer is beyond important, especially when you’re working with sensitive files in personal or workplace environments. There are numerous tasks you are advised to do, such as install an anti-virus program for Windows or correctly set up a firewall. However, those only protect you from remote threats.
In case your system is stolen, doing things such as encrypting your hard drive and securely deleting your files can prevent the thief from reaching the data they may be looking for. Today we’ll be focusing on how to delete your files securely to prevent their recovery, and how you can accomplish that on a Linux system.
There are a number of different options available for you when it comes to secure deletion and wiping. The first one is a utility called
shred. With it, you can delete files as well as hard drives securely. It should already be installed on your Linux system by default, so no installation of the utility is necessary.
To “shred” a file, you simply need to run the command
shred /path/to/file. This will overwrite the data that the file in question takes up, but the file itself will still appear as it hasn’t been deleted. To run the utility and have it delete the file, you can run
shred –-remove /path/to/file. Finally, shred only overwrites the data a few times by default. To change this setting, you can run
shred -–iterations=50 /path/to/file to have shred overwrite the data 50 times. Of course, you can change the number to whatever you please, but remember that a higher number will take longer to complete. You can also combine flags, such as
shred –-remove –-iterations=50 /path/to/file.
Using the utility to wipe hard drives completely is another command away. The command I would recommend is
shred –vfz –n 10 /dev/sdX, where
sdX should be replaced with the hard drive’s actual identifier. If you’re not sure what identifier the disk or partition in question has, check the Disks application. The
–v flag shows the progress of the operation, the
–f flag changes any file permissions so that the operation can successfully complete, the
–z flag makes shred overwrite with zeros during the final run, and the
–n flag followed by a number dictates the number of overwrite runs shred should perform.
If you are in need of any other settings, you can find them by running
If you are specifically looking to wipe a hard drive or other device, you can also complete that task with the
dd utility, which is most commonly used for copying partitions or writing ISO images onto USB drives. You can overwrite a hard drive or partition with zeros by running the command
sudo dd if=/dev/zero of=/dev/sdX bs=1M. You can also overwrite the drive or partition with random data instead of zeros by running the command
sudo dd if=/dev/urandom of=dev/sdX bs=1M.
Sadly, dd does not come with a progress bar of any kind, so you’ll have to sit in front of your monitor for a while watching a blinking cursor.
Finally, if you want a graphical alternative to shredding files, I recommend you try out BleachBit . While the tool does not work for scrubbing an entire partition or hard drive, it is an effective tool for deleting files in a secure manner as well as wiping free space. You can accomplish these tasks by launching BleachBit after installation, and then choosing an option from the File menu.
Also called the “CCleaner for Linux,” BleachBit can help tidy up your system in the process. Deleted files can also by shredded, as configured in the program’s settings.
As you can see, there are a number of different ways for you to quickly and easily shred or wipe your files, partition, or hard drive. It’s really up to you how you want to complete the task, and this list doesn’t include all possible options, but these are the most common and the ones I’d recommend the most.
When have you had to delete files securely? What tools did you use? Let us know in the comments!
Image Credit: Red Lock via Shutterstock