4

I don't know how I put myself in these situations.

So I was fooling around with dscl late last night, making and removing accounts, when suddenly I ran dscl . -delete /Users instead of dscl . -delete /Users/someuser.

So now I have no users on my machine, all that works is single user and recovery HD.

What do you think is the best way to fix this? It seems to me like doing the re-install from recovery HD will restore the system users and leave my files alone. I've found another answer from a few years back (link) where OP says the installer hanged (hung?) when he tried that. However, he was running 10.6, where I'm running 10.9, and the restore mechanism is different. Has anyone else been in this situation?

I'm thinking of doing the re-install and, if everything works fine, re-creating my user with the original home folder with DSCL. What I don't know is how safe that is.

Also, I don't have a backup of any kind.

All that really matters is not losing anything in my home folder. If I have to copy all of my files off to an external HD and do a wipe and install, I'll do it. I'd just like to avoid such extremities if at all possible.

2 Answers 2

1

Indeed, that should work.

Reinstall using the Recovery HD, then create a new user account with a unique name using the Setup Assistant. Once booted, you can open Users & Groups from System Preferences and create your original user again. Providing you use the same short name, this should prompt you to associate the existing home folder to the new user account.

However, you can't be too careful, and making a backup would always be wise. If you have OS X installed on an external drive (or are willing to install it on an external drive), you can boot into that and use that to obtain the files. Alternatively, you can boot into Single User Mode, mount another drive (mount /dev/disk1s1 /Volumes/externaldisk) and copy the files over.

2
  • 1
    This worked beyond my wildest dreams. Now I know I'm pretty much covered if I screw around with dscl in the future. In case someone happens upon this in the future, I have a few things to add. First, after recreating my original account, my temporary admin accound had UID 501 and my real account UID 502, so I switched the UIDs with dscl in single user mode. In addition, my user 'tmpadmin' somehow managed to gain ownership of most of my home folder, but that I solved using the answer to this question.
    – SlEePlEs5
    Commented Mar 2, 2014 at 21:43
  • @SlEePlEs5 Great! FYI, there's an official ACL tool for fixing home folder permissions.
    – grg
    Commented Mar 2, 2014 at 22:06
0

Couldn't you delete /var/db/.AppleSetupDone file? Then the computer should start with that little song-and-dance and create a new user. Once that is done, you can move the home directories around and reset things as you like.

1
  • True, but the main issue was that all of the system users were deleted as well, and there's no way I could have recreated all of those manually, with the correct groups and permissions. I'm not even sure there was still technically a root user in the system, my impression is the whole 'Users' table was deleted. On my current machine, dscl . -list /Users | grep _ | wc -l returns 73 system users (which, on OS X, start with an underscore).
    – SlEePlEs5
    Commented Jul 16, 2014 at 19:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .