22

I created a new Admin account in Sierra High and needed to delete the previous admin account which is marked now as the standard user. However, after unlocking as admin and selecting the respective user that I would like to delete, I see the - sign is marked as Grey.

enter image description here

This is all accounts and I would like to delete the mac user account,

$ dscacheutil -q user | grep -A 3 -B 2 -e uid:\ 5'[0-9][0-9]'
name: mac
password: ********
uid: 501
gid: 20
dir: /Users/mac
shell: /bin/bash
--
--
name: chaklader
password: ********
uid: 502
gid: 20
dir: /Users/chaklader
shell: /bin/bash

How do I delete the respective account? I find a code snippet to run on the terminal, i.e, sudo /usr/bin/dscl . -delete "/Users/mac". Should I try that and will work out?

Update:

As an answer suggested, I'm not logged in to the the fast user switching menu.

enter image description here

As it was asked, I run who in the terminal and get the result,

$ who

chaklader console  Dec 28 06:01 
chaklader ttys000  Dec 28 14:51

So, in brief the other user, mac was not in the terminal.

5
  • Does converting the standard user to an admin change anything?
    – drivec
    Commented Dec 27, 2017 at 18:01
  • You most probably can’t remove the mac user because it is active and locks system ressources (for example he might have mounted an external disk and be sitting on it). To check this possibility, enter the who in a terminal.
    – dan
    Commented Dec 28, 2017 at 8:49
  • I indeed upgraded to new SSD of 750 GB and the user I would like to delete was the main admin 👨‍💼
    – Arefe
    Commented Dec 28, 2017 at 8:51
  • @danielAzuelos see my updated question.
    – Arefe
    Commented Dec 28, 2017 at 8:59
  • just FYI: I didn't need to do this in the Catalina OS
    – Arefe
    Commented Nov 4, 2020 at 5:19

4 Answers 4

6

I had a very similar problem to this. With the help of Apple Support I solved it. I posted the solution here: https://discussions.apple.com/message/33849669

Repeating that here, it is:

  • Boot into the recovery partition.
  • Choose Terminal from the Utilities menu --> Terminal should appear.
  • Enter: resetpassword at the prompt and hit return --> a new window/app should appear behind the Terminal window called "Reset Password"
  • Go through the steps to reset the password for the account you're trying to delete.
  • Restart the Mac and log back in as your main admin account.
  • Go to Users & Groups System Preferences pane, select the account you're trying to delete and hit the minus button.

Fixed it for me. Hope this helps!

1
  • hi david, I reinstalled the High Sierra OS due to its gets slow and decided to try your method. I can confirm that it works fine
    – Arefe
    Commented Sep 22, 2018 at 14:11
28

The – button is greyed out for a user when the user is still logged in with Fast User Switching. Log out the other user you're trying to delete, then return to System Preferences with this user account and try again. You can restart to be sure that user is inactive as well.

You can delete a user from command line and you need to be careful you have the exact short name correct or you will erase the wrong data. In this case, the short name is mac. Run the following to delete the user and separately delete the user's home folder. If you want to keep the home folder, don't run the rm command.

sudo dscl . delete /Users/mac
sudo rm -rf /Users/mac

If the dscl command fails, reset the password on the account and retry the above commands.

sudo passwd mac
2
  • 1
    Comments are not for extended discussion; this conversation has been moved to chat.
    – bmike
    Commented Sep 8, 2018 at 22:03
  • 4
    For those of you getting here after me, this is the solution. Don't bother booting into a recovery partition; it is completely unnecessary. Just reboot your machine and then remove the user.
    – mlg87
    Commented Mar 16, 2019 at 4:42
2

Both of the above answers are great places to start but I found that those methods may not always work. In the case that the above answers fail, you can try the following :

  1. In Terminal, enter the following (enter the password for root when prompted):
    sudo -s
    cd /var/db/dslocal/nodes/Default/users
    rm -f username.plist
    rm -rf /Users/username
    reboot
    

The above commands grant your shell admin / root permissions, delete the property list file for the user, and clear the home directory. If your user has an alternate home directory - use care to determine that before deleting the preference file.

3
  • Using sudo, and with Full Disk Access enabled for Terminal.app, on macOS 11.2.3, I get override rw------- root/wheel for username.plist? but then: rm: username.plist: Operation not permitted. Suggestions? Commented May 24, 2021 at 17:44
  • 1
    @JasonHarrison do you have System Integrity Protection enabled? You can check by going to Terminal and entering csrutil status. System Integrity Protection is a macOS security feature that will prevent even root from modifying important system files. To disable it, go to macOS Recovery > Utilities > Terminal and enter csrutil disable. After a restart it should work.
    – Todd
    Commented May 25, 2021 at 1:06
  • 1
    Hi @JasonHarrison I've edited this and if you need to open a new thread, just link here or ping me in comments and I'll have a look for you
    – bmike
    Commented Mar 12 at 17:10
1

Follow the command to Delete a User Account:

sudo /usr/bin/dscl . -delete /Users/<USER_ACCOUNT>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .