Create a new Mac Administrator account using Single User Mode

If you ever need to recreate admin account on your Mac, this is the quickest and safest way to do it without breaking your Mac:

  1. Boot into Single User Mode by pressing ⌘ + S before you hear the Apple chime.
  2. Mount the drive by typing /sbin/mount –uw / then ↩ enter.
  3. Remove the Apple Setup Done file by typing rm -v /var/db/.AppleSetupDone then ↩ enter.
  4. Reboot by typing reboot then ↩ enter.
  5. Complete the setup process, creating a new admin account.

This will force macOS to redo the initial first account creation, and doing so will not affect the current user profiles (they will remain intact) – so, if you prefer to make them as admin later, you can do that as well by logging in using the newly created admin account, then go to System Preferences, then Users & Groups, select the existing user, and tick “Allow user to administer this computer.

I tested on macOS 10.14 Mojave and it worked:

ark:db andy$ pwd
/var/db
ark:db andy$ ls -al .AppleSetupDone
-r--------  1 root  wheel  0 Apr  4  2017 .AppleSetupDone
ark:db andy$ uname -a
Darwin ark.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
ark:db andy$

If you have any questions or comments, please feel free to post down below. Cheers!