How do I delete a user on Mac terminal?

Answered by Stephen Mosley

Deleting a user account on macOS can be done through the Terminal using the dscl command. The dscl command is a directory service command-line utility that allows you to interact with the Directory Service data store on macOS.

Here are the steps to delete a user account on Mac using the Terminal:

1. Open the Terminal: You can open the Terminal by going to Applications -> Utilities -> Terminal. Alternatively, you can use Spotlight Search (Cmd + Space) and type “Terminal” to open it.

2. Check the list of user accounts: Before deleting a user account, it’s a good idea to check the list of existing user accounts on your Mac. You can do this by running the following command in the Terminal:
“`
/usr/bin/dscl . -list /Users
“`

This command will list all the user accounts on your Mac.

3. Find the user account you want to delete: Look for the username of the user account you want to delete from the list generated in the previous step.

4. Delete the user account: Once you have identified the username of the user account you want to delete, you can use the dscl command to delete it. Run the following command in the Terminal, replacing `` with the actual username of the account you want to delete:
“`
Sudo /usr/bin/dscl . -delete /Users/
“`

For example, if the username you want to delete is “dylan”, the command would be:
“`
Sudo /usr/bin/dscl . -delete /Users/dylan
“`

You will need to enter your administrator password when prompted.

5. Verify the user account deletion: To confirm that the user account has been deleted, you can run the list command again:
“`
/usr/bin/dscl . -list /Users
“`

The deleted user account should no longer appear in the list.

It’s important to note that deleting a user account will permanently remove all associated data and files belonging to that user. Make sure you have a backup of any important data before proceeding with the account deletion.

Deleting a user account through the Terminal can be a powerful tool, but it’s essential to exercise caution and double-check the username before executing the delete command to avoid accidentally deleting the wrong account.

I hope this guide helps you in deleting a user account on your Mac using the Terminal. If you have any further questions, feel free to ask.