How To Securely Delete & Wipe Data [Linux]

Intro Image cropped   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.

Shred

linux wipe shred   How To Securely Delete & Wipe Data [Linux]

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 man shred.

dd

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.

BleachBit

linux wipe bleachbit   How To Securely Delete & Wipe Data [Linux]

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.

Conclusion

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

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

12 Comments -

0 votes

Alberto Lerma

To wipe the whole hd Terminal doesn’t ask you for root permissions? I THINK the command should start with “sudo”. Great tools btw thanks.

0 votes

Danny Stieben

Did I leave that off? My apologies!

0 votes

Shon Nelson

I have used bcwipe for years, mostly for wiping free space for also for complete drive wipes

0 votes

Danny Stieben

I’ve never heard of bcwipe. I’ll have to check it out!

0 votes

Adrian Rea

I work in a data wiping environment. we use a bespoke system but for consumer purposes it may have been useful to give a bit more depth to the article on how and why we need to wipe. Theft is only one part of the need. Selling drives can be to unscrupulous people who buy second hand drive purely to scan for fraud. Then there are broken drives, sent to the recycle yard but can often be put back together and individual plates may still fully or partially work. I would recommend encrypting data with a key you can remember! But even some encryption can be crack I see today https://windowssecrets.com/newsletter/legitimate-app-breaks-popular-encryption-systems/
Even though you know this you need to state that cannot wipe an OS when still using that OS! You need to use another OS on a separate partition, drive or removable media. It’s simple to us but others may shoot and ask questions later!

0 votes

Danny Stieben

Thanks for all the tips, Adrian!

0 votes

dragonmouth

Danny,
I think you need to check the usefulness of the shred command. According to “man shred” shred will not be effective for: Journaled files, RAID, NFS and compressed files. That pretty much excludes all files in a modern Linux file system.

0 votes

Danny Stieben

Huh. I did my research and that little bit didn’t show up. Thanks for letting me know.

0 votes

Nevzat Akkaya

If you consider secure delete / wipe operation on a hard disk, you should use HD manufacturer’s special wipe cd and initiate secure wipe operation on chip level (I mean ATA commands). This way it will be faster and more secure. You can check out this page for more info : http://tinyapps.org/docs/wipe_drives_hdparm.html

0 votes

Danny Stieben

Thanks for sharing this method!

0 votes

Daniel

Thanks for the article! Do you know of a way to add a bleachbit option to the trash, standard delete function, or to the right-click menu?

0 votes

Daniel

Thanks for the article! Do you know how to make the regular ‘delete’ function use dd or bleachbit when wiping the files? Or even to add a bleachbit option to the right-click menu?

Thanks again!