MacOS – How to reenable admin privileges without an administrative user

macos

I installed server and fiddling around settings and I unchecked administer this account and the server crashed immediately.

Now I am listed as standard user and cannot perform any changes:

$ dscl . -read /groups/admin GroupMembership
GroupMembership: root

I thought there will be atleast 1 user to administer the whole computer excluding root :(. How can I get back. Quite panicked as I might loose everything.

Best Answer

You can try whether sudo -s still works (which would allow you to add yourself to the admin group again), but probably it won't.

Do the following

  • Reboot into Single User mode by keeping Cmd-S pressed during reboot
  • /sbin/mount -uw /
  • rm /var/db/.AppleSetupDone
  • reboot

This will trick your Mac into behaving like a new installation (but with your data still intact). Follow the setup without migrating any data etc., near the end you will have the option to create a new user with admin privileges. Make sure to pick a new username here to avoid any conflicts.