Recursivly Deleted Root Directory [duplicate]
I recursively deleted the contents of my root directory with sudo privileges. My display reset, and windowing stopped working. I could no longer run non-buitin commands. Most of my directories (including the home directory disappeared).
What I meant to run:
sudo rm ./* -rf
What I believe I ran:
sudo rm /* -rf
I understand how this command works (see What does rm -rf do?).
I'm trying to get a better sense of how much (and what parts) of the original files and directory-structure physically remains on the hard-drive.
How much of these "remains" are recoverable? E.g is it possible to use data recovery software like TestDisk/PhotoRec to recover the full home dir itself? What about config files?
What happened
That can be looked up in the man
pages. rm
deletes files and with the arguments -r
(for recursively) and -f
(for "forcefully").
In short it that command deletes every file (and directory) which is a child of that path. In your case /
Usually there should have been a warning about deleting your root directory (--no-preserve-root
flag), though as I have never run that command myself (yet) I can't confirm if that happens everywhere.
How can I recover from an rm -rf
Data recovery isnt just running a few commands and be done with it. As the answer below states data recovery is a science.
Usually your best shot (best as in getting the most databack) if in fact everything was deleted is bare-metal recovery, though if it is financially viable is up to you to decide.
See this question over on serverfault for waht next steps to take: https://serverfault.com/questions/587102/monday-morning-mistake-sudo-rm-rf-no-preserve-root