Securitate

How do I completely wipe my hard drive in Ubuntu?

How do I completely wipe my hard drive in Ubuntu?
Usually Linux users use the command rm to remove files and directories. When we remove a file using the command rm we are labeling the removed file or directory as “rewritable space” on the disk. Therefore the removed data can be restored if wasn't overwritten by another piece of data as explained in previous articles on computer forensics and data recovery.

In this tutorial 5 tools to carry out a full removal of data, wipe, srm, dd, shred and scrub are shown. The programs can be executed from live cd distributions to wipe the hard drive completely.

WIPE


The wipe command allows us to fully erase data from our disk, it rewrites the sector and flushes the cache making it impossible or very difficult to retrieve the data.

To install wipe on Debian/Ubuntu type:

apt install wipe -y

The wipe command is useful to remove files, directories partitions or disk.

To remove a single file using wipe type:

wipe filename

To report on progress type:

wipe -i filename

To wipe a directory type:

wipe -r directoryname

To wipe a partition or disk speeding up the process add the parameter -q,  type:

wipe -q /dev/sdx

Note: replace sdx for the proper device.

The last example will wipe everything from the disk or partition without possibility to restore it, type man wipe in the terminal to see all options available.

SRM

srm overwrites the data before deleting it, it is a similar option to wipe. To install srm on Debian or Ubuntu type:

apt install secure-delete

Type man srm to see the available options

As you can see similarly to rm you can use

To remove a file:

srm filename

To remove a directory:

srm -r directory

For additional information on srm type:

man srm

DD

DD can be used to overwrite a disk. If you formatted a disk you can run the following command to fill the disk with  random data, making it impossible to restore. Replace the X for the proper disk. Dd overwrites the disk with zero and allows us to format the device in different formats. It comes by default on Debian and Ubuntu based distributions.

To fill a disk with random data using dd run:

dd if=/dev/urandom of=/dev/sdX bs=4k

For additional information on shred on the terminal type:

man dd

SHRED

Shred is another alternative to safely remove data, it comes by default on Debian/Ubuntu if it doesn't type:

apt install coreutils

Shred is simple to use too, to overwrite  a file just type:

shred

After an ls we see the directory is still there,it was overwritten, to remove it after writing add the -u parameter:

As you can see after the -u there is not linuxhintshred directory.

For additional information on shred type:

man shred

Scrub

Scrub is another tool to overwrite data in hard disks, Scrub writes patterns on files or devices making the data retrieval more difficult. Scrub works in 3 modes detailed in the main page, the default mode is the most effective one.

to install Scrub run:

apt install scrub

Type

man scrub

As the man says we can wipe a disk by running:

scrub /dev/sdX

To create a directory and fill it with files until the system is full run:

scrub -X

For additional information on Scrub option and parameters, in the console type:

man scrub

I hope you found this tutorial useful to get your data fully removed, should you have any inquiry contact us opening a ticket support at LinuxHint Support. Keep following LinuxHint for more tips and updates on Linux.

Tutorial Shadow of the Tomb Raider pentru Linux
Shadow of the Tomb Raider este a douăsprezecea completare a seriei Tomb Raider - o franciză de jocuri de acțiune-aventură creată de Eidos Montreal. Jo...
Cum se mărește FPS în Linux?
FPS înseamnă Cadre pe secundă. Sarcina FPS este de a măsura rata de cadre în redările video sau în performanțele jocului. În cuvinte simple, numărul d...
Cele mai bune jocuri Oculus App Lab
Dacă sunteți proprietarul căștilor Oculus, atunci trebuie să fiți informați despre încărcarea laterală. Încărcarea laterală este procesul de instalare...