I ran into this problem a little while back and thought I should document it. It’s kinda similar to the “How to get Admin rights in OSX Leopard using single user mode…” document from earlier this year. Here is the procedure:
- Boot into single user mode. Hold Command-s at startup.
- Check the filesystem: /sbin/fsck -fy
- If no remaining errors, mount the filesystem: /sbin/mount -uw /
- Start up directory services:
launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plistNote that single user mode said to use com.apple.DirectoryServicesLocal.plist, but that didn’t work — this did.
- Find what groups the user belongs to: dscl . -list /groups GroupMembership | grep username — repeat for each group except for the user’s own group.
- Remove the group corresponding to the username: dscl . delete /groups/username (this may not be necessary — you may get an error that the group doesn’t exist; you can ignore it and go on).
- Remove the user account: dscl . delete /users/username
- At this point, you may wish to remove or archive the user folder in /Users.
- You may wish to remove the .AppleSetupDone file in /var/db to cause the Setup Assistant to run when next booted.
- All done? Type reboot to reboot the system or shutdown -h now to shut down the system.
Nice and squeaky clean…..