How can I recover from mistaken 'rm *'?

1

I just typed rm * in the wrong directory by mistake. I had the wrong terminal window highlighted. What are my options?

jononomo

Posted 2013-01-19T21:32:33.723

Reputation: 287

4Just restore from your latest back-up - that's the whole point of having a back-up strategy, after all. – Paul R – 2013-01-19T21:34:38.673

I have a backup, but I will lose about 3 hours of tight deadline work. – jononomo – 2013-01-19T21:35:56.280

2

this tool has worked for me in the past: http://extundelete.sourceforge.net/

– None – 2013-01-19T21:47:41.623

If there was activity on the machine (writing files, particularly), the space the deleted files used to occupy is probably already recycled. Chalk it up to "Unix learning." My condolences. – vonbrand – 2013-01-23T18:17:31.937

@PaulR Also, I'd like to point out that Paul R's response is not helpful and does not address the question since it is obvious from context that I was not able to simply restore the work I lost from backup. So his comment serves no purpose other than to express condescension -- and moreover, he seems to incorrectly assume that I had no backup whatsoever. Generally speaking, I find StackExchange more useful when comments are pertinent to the question that was asked. – jononomo – 2013-01-24T01:15:52.213

1

Now it's on SuperUser, can be closed as a dupe: http://superuser.com/questions/32355/undo-linuxs-rm?rq=1

– therefromhere – 2013-02-16T05:37:25.103

Answers

5

What you can do is re-do the three hours of work, and then think about aliasing your rm command to a script which works like rm but stages deletes through a trash bin directory which must be explicitly emptied before the files are really gone.

Kaz

Posted 2013-01-19T21:32:33.723

Reputation: 2 277

1

I know this is an old answer, but aliasing rm isn't a great idea, since you'll get too comfortable with rm being a 'safe' command and if you make a mistake on another computer, it could mean real data loss. Instead alias something like myrm or something, that way if you run it on another computer, nothing bad will happen, and you'll have to think about using rm correctly. See this answer for more detail.

– Adam – 2014-08-13T21:39:47.170

@Adam So then, the opposite: alias rm to a command which prints "lose the habit of using rm" and exits with an error. :) – Kaz – 2014-08-13T23:38:42.810

0

Do as Paul -R Says, I think if i remember correctly, if write operation has occurred then its not possible to UNDELETE the item....

Maybe you can find more information here.... http://www.computerhope.com/undelete.htm

Zeddy

Posted 2013-01-19T21:32:33.723

Reputation: 111