rm does not permanently delete files

Dawson Botsford
3 min readMay 18, 2016

--

When using the terminal command rm (or DEL on Windows), files are not actually removed. They can still be recovered in many situations, so I made a tool to truly remove files from your system called skrub. Skrub will only work securely on file systems that overwrite blocks in place.

What is rm actually doing?

When you use the rm command, you are simply unlinking it. This means that the file data is still on your system. Your computer simply removes the filename association to it and “frees” it.

The gotcha about freeing a file is that it remains on your system until your computer needs that memory space. That can be a problem. What happens when you have sensitive data and need it to be removed?

NEVER try that at home

As you may know from experience, salvaging an rm’d file can be difficult. There are no user-friendly methods for this, yet there are advanced tools that black-hats know how to use like scalpel, magicrescue, and many others.

Skrub your files instead

To remedy this, I have been using skrub, an open-sourced file remover I made. What does skrub do differently? Before removing your files, skrub first floods the file with zero-filled bytes. This means that the memory locations will undergo this process:

File contents before skrubbing (utf-8 view)
File contents after skrubbing (hex view)

Then and only then, is the file removed. This method works well on a considerable number of file systems, but not all of them. These cases are noted in the FAQ.

Fancy Features

When building a tool like this, you find alternative options and other implementations. For example, rm has a -P flag for memory flooding. Yet I truly believe that skrub is the easiest to use file remover.

Why Skrub?

  1. Skrub is “-rf” by default. There are no flags needed for daily use:
skrub * == rm -rf *

2. Skrub supports file globbing:

skrub *.js index.html

3. Skrub supports negation in globbing (skrub this but not this):

skrub *.txt '!importantThing.txt'

Feedback and support for more features appreciated at https://github.com/dawsonbotsford/skrub

--

--

Dawson Botsford

Freelance React Programmer. Adorer of JavaScript & lattes. Previously @ Uber and other startups. https://dawsbot.com