I have been a Linux user for quite some time now. And I can say that some powerful tools can lead to disaster when not correctly used.







rm is a powerful tool. If you have 1000 files in your folder with different file types, and you want to delete all of the jpegs, UI might not be practical here. Clicking and selecting 300 jpegs out of 1000 mixture of files is quite tiresome.

Or removing files that starts with the letter “f” among the 1000 files could be tiresome too.

This is where rm comes in. A powerful removal tool piped with Unix’s grep would do the job.







I have been a victim with rm ‘s disaster twice already. The first time I experience it, all my important files are gone. Then followed by a panic! (waaaaah!!!)

I googled and researched how to retrieve files deleted by rm .

The result? Hopeless.







Desperation rises, until I got tired in researching and finding ways.

I just cannot find a way to recover the lost files. Where did it go? It didn’t go to Trash. It didn’t go to Recycle Bin. (What? Recycle Bin? Stop mentioning Windows term in this Linux article)

rm is really something you should be cautious when using. I could still remember the 2nd time I experience the menace of rm . Here’s what happen:

me@Debian:~/legals$ ls ~/miscFiles

pieceOfTrash.txt tmp.txt notImportant.jpg readMe.rtf junk.pdf junks.pdf andMoreJunks.pdf

I am currently in the legals/ folder. All of which contain important documents.

After ls -ing, and after peeking at the files in the miscFiles/ folder, I found out that all of those files are worthless.

I decided to delete them……………….later. I need to go to the bathroom first.







Then I come back to my Linux. Looked back at the ls result:

pieceOfTrash.txt tmp.txt notImportant.jpg readMe.rtf junk.pdf junks.pdf andMoreJunks.pdf

Then delete them as planned:

me@Debian:~/legals$ rm -rf *

KABOOM!!!

And the disaster manifested!

For those who didn’t get what happened, here’s the explanation:

First, I am currently in the legals/ directory where my important files are placed.

Second, I peeked at the miscFiles/ folder and found out it’s all worthless files. They are all to be deleted.

Third, I went to the bathroom. (Just don’t ask what I did back there)

Fourth, I went back to my chair. Looked back at the ls results. And typed ` rm -rf * ` to delete all files.

But what’s deleted is my legals/ files because this is where I am currently situated.

THE LESSON

After two painful experience, I learned my lesson.

Be cautious next time when using rm . Here’s my tip before using the tool.

First, do ls before rm :

me@Debian:~/legals$ ls ~/miscFiles/*

Second, copy the previous command, and replace ls with the appropriate rm

me@Debian:~/legals$ rm -rf ~/miscFiles/*

I always make sure I ls first before rm . Then replacing the ls with rm if you’re good to go.

There are lot of precautionary ways. This is just one of them.

So, there you go. I hope you learn from this article.

If you want to share something, place it in the comments section below.





