On OS Catalina Delete the account you are currently logged into
I have a Macbook Air, and I am logged into an administrator account which I want to delete. Is there a way to delete the account I am currently logged into while using that account?
Solution 1:
The closest you can get to delete your admin with the name admin_username (even with no other user left afterwards) without logging in as a different user in the GUI is to enable root and remove your admin with the superuser:
- Open Terminal.app
- Enable root with
dsenableroot
. You have to enter your admin_username password and choose a new password for root and verify it. - Change to root:
su -
and enter root's password. -
Enter:
rm -dR /Users/admin_username; dseditgroup -o delete -n . -u admin_username admin; dscl . delete /Users/admin_username; reboot
The password of admin_username is probably required. I ran several tests with various permutations of the command above and either
dseditgroup
ordscl
asked for it.Warning: This will remove all admin_username files & folders! Most files can be recovered with a data recovery tool.
Afterwards the root user will be enabled and depending on your settings it will be visible as "Other users..." on the login screen.
The command was tested in a virtual machine. The admin user had a relatively small user folder (< 5 GB). On a real machine your milleage may vary.
Reading and interpreting all related questions and comments I suspect that the MacBook Air is a shared computer with two admin accounts belonging to different parties (PvsP/PvsB) being at loggerheads in the meantime.
I would hand over the computer to a wise, reliable and neutral person, explain the dilemma and expect a Solomonic solution.