In the next section of this article, Mytour will guide you through 3 ways to permanently delete data on Linux, Ubuntu. Including using the DD command, the Shred tool, and Darik's Boot And Nuke tool.
Note: Shred and DD require users to know the character assigned to the drive they want to delete data from. To find the character assigned to the hard drive you want to delete, open Terminal and enter the command 'lsblk' into it. The command will return the corresponding hard drive name.
Using DD command to permanently erase data on Linux, Ubuntu
The most common method to securely erase data on Linux, Ubuntu is to use the DD command. Although this method is not fast, however, in practice, most Linux and Unix systems come pre-installed with the DD tool so accessing and erasing hard drives is easier.
One thing to note is that DD does not erase data on the drive in use, meaning you cannot use DD to erase the system drive on Linux, Ubuntu. Instead, you will need to remove the hard drive and install it into another computer or boot from a Linux Live CD.
Assuming you have performed one of the two methods above. Next, follow the steps below to permanently erase data on Linux, Ubuntu using the DD command:
Step 1: Ensure the hard drive is not mounted. If it is attached, use a file manager to detach it. Alternatively, you can use the unmount command.
Note: In the command below, replace X with the actual drive name and Y with the partition number (such as /dev/sda1).
sudo umount /dev/sdXY -l
sudo dd if=/dev/urandom of=/dev/sdX bs=10M
Using /dev/urandom to write zeros across the entire hard drive will take a considerable amount of time. The best approach is to use DD and let it run overnight.
To check if the DD command has completed, you enter DD into the Terminal window again.
Using Shred to permanently erase data on Linux, Ubuntu
In addition to the above method, you can use the GNU Shred tool to permanently erase data on Linux, Ubuntu. Similar to DD, the GNU Shred tool is integrated into all Linux distributions, in some form. However, GNU Shred can erase all files and the entire hard drive.
If you want to delete all data on the hard drive, but not the entire file system, GNU Shred is the ideal choice for you.
Deleting files using Shred:
shred -u file.odt photo1.png photo2.zip
Or:
find /path/to/folder/to/shred/ -exec shred {} ;
Finally, use the Shred tool to delete the hard drive by running the command below:
sudo shred -vfz /dev/sdX
Note: Replace X with the drive name (such as /dev/sda).
Similar to DD, using Shred to erase hard drive data takes quite a long time. It's best to let the tool run overnight and erase everything. If the Terminal allows you to enter the command again, it means the process has finished.
Another way to permanently erase data on Linux, Ubuntu
If DD and Shred are not powerful enough to securely wipe hard drive data, you may consider using Darik's Boot and Nuke (DBAN) tool.
The open-source Boot And Nuke tool will wipe all data, everything on your computer or connected to your computer. Using DBAN requires a Live Linux USB. Download the Etcher USB imaging tool and the latest DBAN ISO image and install them.
Download the Etcher USB imaging tool to your computer and install it here: Download Etcher
Download the latest Darik's Boot and Nuke tool to your computer and install it here: Download Darik's Boot and Nuke
After downloading and installing the tools, open Etcher USB and use the tool to flash the DBAN ISO image. Then restart your computer to access the BIOS and change the bootloader.
Different computer models have different ways to access the BIOS, readers can refer to the article access BIOS, accessing BIOS of common Hp, Asus, Acer, Vaio, Dell, Lenovo laptops by Mytour for instructions.
Note: Disconnect any hard drive that you do not want to delete data on your computer. This is because DBAN will delete everything connected to the computer.
On the DBAN startup window, type autonuke at the command prompt. This command will automatically delete everything connected to the computer. Therefore, make sure the hard drives you do not want to delete are not connected to the computer.
Run the autonuke command to open the DBAN user interface. The process of scanning and deleting data on the hard drive will take some time. After the process is complete, the screen will turn black and display a message saying: 'All selected disks have been wiped'. Press any key to continue.
By permanently deleting data on Linux, Ubuntu, you can rest assured that the data will be completely erased from the hard drive, freeing up space for other data.
On Windows, you can also use various methods to delete files and data you don't want to keep. You can utilize built-in features or dedicated file deletion software available on the internet today.