Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

atonaldenim

macrumors regular
Original poster
Jun 11, 2018
243
317
Let's say you've fixed up a classic Mac Pro, and it's going to a new home. You've installed a new GPU and upgraded the OS to Mojave, maybe preloaded some useful apps like Macs Fan Control, or given the NVMe boot drive a better looking Finder icon. You don't want to completely reinstall macOS, you just want to delete your user account and let the new owner run through the Apple Setup Assistant first boot experience just like it was a fresh install. If you look it up, all the instructions online will tell you to delete /var/db/.AppleSetupDone, and then reboot into Single User Mode to delete your user account.

But wait, you can't use Single User Mode, because your new Mojave-compatible GPU doesn't have a Mac EFI. No boot screen = no single user mode! :eek: But have no fear, here's a surefire method to delete your own user account in Mojave, without Single User Mode, and prepare the Mac Pro to re-run the Apple Setup Assistant as if it were fresh from the Apple Store. (Should work on other Mac models and other versions of macOS too.)

Get ready. This process will all happen at once, without a reboot. It's committing harakari. It's the last time you'll ever be logged in to this user account. Make sure you've tidied everything up on the hard drive, backed up any files you want to keep, deleted anything you don't want to leave behind, and are completely prepared to say goodbye.
  1. Make sure you've deleted any other user accounts, leaving just one administrator account left.

  2. Log in to the administrator account you want to delete.

  3. Open a Terminal window.

  4. In the Terminal do cd ~ && pwd to determine the path to your user's home directory. We'll use this later when we delete the home directory.

  5. Now run sudo -s to open a root shell, then enter your password.

  6. Now that the Terminal's in a root shell, enter rm /var/db/.AppleSetupDone (Deleting that empty file will re-run Apple Setup Assistant on the next boot.)

  7. Leave this root terminal window open!

  8. Now to delete your user, open Directory Utility ( /System/Library/CoreServices/Applications/Directory Utility.app )

  9. In the Directory Utility window, click the lock icon in the bottom left to authenticate, and enter your password.

  10. Now choose Edit > Enable Root User. As root, you'll be able to delete the account you're currently logged in with. (If "Enable Root User" is greyed out, try File > Connect, Address: localhost. If it says "Disable Root User" instead, then you've already enabled root and can skip to Step 12.)

  11. Set a password for the root user.

  12. Now click the lock icon again to close the lock and un-authenticate from your current account.

  13. Next click the Directory Editor icon in the top of the Directory Utility window.

  14. On the Directory Editor page, click the lock icon near the top right, and authenticate with username root and the root password you just set.

  15. Now, in the left column, click on the name of your user account, the one that you're about to delete.

  16. Last chance to turn back! To delete the selected user account, click the button (minus sign) in the bottom left corner of the window, below the column of user names.

  17. You should see the user name disappear from the list, indicating that user name has been deleted.

    If the user isn't deleted, do this: with the same username still highlighted, click the GeneratedUID entry in the top right part of the window, then in the bottom right part of the window, change the last character in the alphanumeric string to something else. Then click the Save button in the bottom right corner, and now you should be able to delete the user as in Step 16.

  18. Almost done. To put things back as they were before, disable the root user that you just enabled. Choose Edit > Disable Root User.

    (If that option is not available, you can type dsenableroot -d in the Terminal instead. When it asks for a password, enter the root password you created.)

  19. Now you've deleted your user account from the system, but its home directory files are still there. To delete the user's files, click back in the root terminal that you left open from earlier. (It will still work even after all that!)

  20. In the terminal, do cd /

  21. Now the last command. To delete the user's home directory & files: rm -rf /Users/username (where /Users/username is the path to your user's home directory you confirmed in Step 4.)

  22. All done! The only thing left is to power down: shutdown -h now
The next person who turns it on will be greeted with a welcome screen, and no idea any other user accounts ever existed. :cool:

Bonus tips:
  • You can check your work by booting into Recovery Mode, hold Cmd + R at startup before the boot chime. Your OS drive should be mounted under /Volumes/ and you can access its files in the Terminal. (if you have a recovery partition on your hard drive)
  • If you've restarted into the Apple Setup Assistant, you can get a Terminal by pressing Ctrl + Opt + Cmd + T. Just in case you needed to do anything else to the system after deleting .AppleSetupDone. More on that here.
 
Last edited:
Thanks for the tutorial! I've definitely clipped it for later.

However, I am confused about one thing. I don't have an EFI graphics card, but I'm pretty sure I can reboot into single-user mode, at least as Apple currently defines it (hold down Command-R to reboot into Recovery Mode, then use Disk Utility and Terminal as needed). I just hold down the Command-R and wait; even though the boot chime is on a black screen, it eventually sorts to a usable screen.

Is being able to get into Recovery/Single-User mode just a useful quirk of my GTX760, or am I misunderstanding something?
 
Thanks for the tutorial! I've definitely clipped it for later.

However, I am confused about one thing. I don't have an EFI graphics card, but I'm pretty sure I can reboot into single-user mode, at least as Apple currently defines it (hold down Command-R to reboot into Recovery Mode, then use Disk Utility and Terminal as needed). I just hold down the Command-R and wait; even though the boot chime is on a black screen, it eventually sorts to a usable screen.

Is being able to get into Recovery/Single-User mode just a useful quirk of my GTX760, or am I misunderstanding something?
They're different things actually, single user mode boots from your normal macOS installation, but stops before it launches the GUI and puts you in a terminal as a root-level user. If you type exit here you'll finish booting into your regular macOS environment.

On the other hand, Recovery mode boots off a separate macOS image that's on a separate recovery partition, not your normal boot partition/OS. You can access the files on your macOS partition, but you're not booted into your normal macOS installation.

Recovery mode is more intended for reinstalling the OS, and single user mode is more for tinkering with your current OS. That said, you might be able to accomplish the same thing in Recovery mode, when I tried I wasn't quite able to complete all the necessary steps, so I found this method to be easier.

Edit: interesting, I didn't realize Apple has redefined "Single User Mode" to mean "Recovery mode" for Macs with T2 chips. Being of an older pedigree, the classic Mac Pro is capable of booting into old school Cmd + S Single User Mode... if you have a GPU that can show the boot screen.
 
Last edited:
Sorry to dig this thread up but also not sorry because it is a fantastic tutorial that anyone reselling a used Mac should see. Thank you Atonal.

Confirmed working on Catalina, although I had to reboot into recovery or use the terminal from setup assistant before I could fully remove the home folder. Seemed like some Library components in use by runtime.
 
Glad it helped @TheOriginalPol! The last time I tried to use it, I found a couple of the steps were slightly different, but the overall idea should still work I think! At least as of Mojave, I haven't gone into Catalina territory or beyond...
 
  • Like
Reactions: Incision
Sorry for dragging up an old thread, but just wanted to say thank you for writing this guide! I was looking all over for instructions that did exactly this and not just allowed setting up a new user.

I just used it on Monterey, and the only thing that I had to do was boot into recovery to finish the deletion of the users home directory.
 
  • Like
Reactions: atonaldenim
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.