In “Delete All Users from Mac OS X [10.5]”, we outlined how to boot into Single User Mode and use Terminal commands to delete the last admin user from a Mac running OS X 10.5. The OpenDirectory system has seen some changes since then and the commands have changed too.
OpenDirectory has gone through some hack job of an update by Apple, and still retains error-check messages that you can safely ignore according to Apple’s own documentation (HT4749):
When running dscl(1) from Single User mode, you’ll see this message:
launchctl: Couldn't stat("/System/Library/LaunchDaemons/com.apple.DirectoryServicesLocal.plist"): No such file or directory nothing found to load
This message can be safely ignored.
So the procedure is as follows:
Start your computer into Single User mode by holding Command-S during startup.
Check the startup disk
Mount the root file system
mount -uw /
launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
Delete the last admin
dscl . delete /Users/username
If you’d like to resuscitate the Setup Assistant
rm -rf /var/db/.AppleSetupDone