1

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

tadasajon
  • 317
  • 3
  • 13
  • 4
    Just restore from your latest back-up - that's the whole *point* of having a back-up strategy, after all. – Paul R Jan 19 '13 at 21:34
  • I have a backup, but I will lose about 3 hours of tight deadline work. – tadasajon Jan 19 '13 at 21:35
  • 2
    this tool has worked for me in the past: http://extundelete.sourceforge.net/ –  Jan 19 '13 at 21:47
  • 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 Jan 23 '13 at 18:17
  • @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. – tadasajon Jan 24 '13 at 01:15
  • 1
    Now it's on SuperUser, can be closed as a dupe: http://superuser.com/questions/32355/undo-linuxs-rm?rq=1 – therefromhere Feb 16 '13 at 05:37

2 Answers2

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
  • 2,631
  • 1
  • 18
  • 23
  • 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](http://superuser.com/a/382498/310285) for more detail. – Adam Aug 13 '14 at 21:39
  • @Adam So then, the opposite: alias `rm` to a command which prints "lose the habit of using rm" and exits with an error. :) – Kaz Aug 13 '14 at 23:38
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
  • 111
  • 4