How To Securely Delete & Wipe Data [Linux]

Danny Stieben 07-02-2013

wipe data linuxMaking 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.


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.


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.


wipe data linux


Finally, if you want a graphical alternative to shredding files, I recommend you try out BleachBit BleachBit - A Utility To Clean Up Your Linux System Read More . 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 Optimize Your System To Run At Its Best With CCleaner Over the last two years, CCleaner has changed quite a bit in terms of version numbers...up now to version 3.10 at the time of this writing. While visually the program actually hasn't changed much (it's... Read More 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

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Benjamin
    November 28, 2015 at 10:37 pm

    WARNING - Shred File and Shred Folder options in Bleachbit are just a simple delete! Recovery software can and will get those back every time. Bleachbit Wipe drive does actually wipe drives (like a USB stick) so no recovery is possible. Bleachbit Clean option is still unknown if it actually 'wipes' (overwrites) of if it is also just a simple worthless delete.

  2. Daniel
    March 17, 2013 at 3:51 am

    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!

  3. Daniel
    March 17, 2013 at 3:43 am

    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?

  4. Nevzat Akkaya
    February 11, 2013 at 11:27 am

    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 :

    • Danny Stieben
      February 28, 2013 at 9:01 pm

      Thanks for sharing this method!

  5. dragonmouth
    February 7, 2013 at 9:47 pm

    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.

    • Danny Stieben
      February 28, 2013 at 9:01 pm

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

  6. Adrian Rea
    February 7, 2013 at 8:19 pm

    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
    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!

    • Danny Stieben
      February 28, 2013 at 9:00 pm

      Thanks for all the tips, Adrian!

  7. Shon Nelson
    February 7, 2013 at 7:12 pm

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

    • Danny Stieben
      February 28, 2013 at 8:56 pm

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

  8. Alberto Lerma
    February 7, 2013 at 6:50 pm

    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.

    • Danny Stieben
      February 28, 2013 at 8:55 pm

      Did I leave that off? My apologies!