Accidentally deleting all OSX users using dscl

Posted by gutch on Server Fault See other posts from Server Fault or by gutch
Published on 2011-02-21T04:33:11Z Indexed on 2011/02/21 7:26 UTC
Read the original article Hit count: 491

Filed under:
|

OK, so I just did something really stupid and deleted all the user accounts on an OSX 10.6.6 machine by running this:

sudo dscl . -delete /users

What I actually wanted to do was delete a single, troublesome account using a command like this:

sudo dscl . -delete /users/localadmin

...but I absent-mindedly pressed return too early and deleted the lot. I've tried using -list and can confirm that I have indeed wiped all the accounts. The machine is currently running fine, but I'm sure that once I log out / reboot then it will be completely broken.

I don't mind that I've deleted the normal user accounts (there was only one I wanted anyway). But it's surely going to be a big problem that system accounts like _installer and _jabber and _lda and _windowserver etc etc are gone.

So my question is, how can I restore the standard set of system accounts? Do I have to reinstall OSX from scratch? Or can I either:

  • undelete those system accounts, or
  • run some command to recreate the system accounts?

© Server Fault or respective owner

Related posts about macosx

Related posts about dscl