How do I completely wipe my hard drive in Ubuntu?: wipe, srm, scrub, shred and dd.

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.


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

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


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

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.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to install SQLite 3 in Ubuntu 20.04 and Linux Mint 20

SQLite is a free, lightweight, and command-line database application. It is an efficient database engine...

Upstart – How is it better or worse than the others?

When Upstart was first conceived by Canonical, the prevailing system was still sysvinit, which started everything in sequence...

5 Best Linux Distributions for Gaming

After writing about Steam on Linux in my last article, I’m here with another gaming article for fellow Linux gamers out...
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019

How to Update Ubuntu Linux

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu

Hướng dẫn cài đặt Apache CloudStack

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader