Max OS X Deleting Users & Groups by Command Line
The Mac Tutorial simply Show How to Remove/Delete Users and Groups from the macOS X Shell Terminal Emulator.
This Process can be Useful in situations like the followings:
-
After the Installation of some Software like MySQL you can have some
problem with the Automatically Created user. -
If you try to add an User or Group from System>Preferences
and you find it already exists but this doesn’t permit you to Login on a
Terminal Session.

So First, you need to open a Terminal Session ( /Applications/Utilities/Terminal.app).
- To Delete a User
sudo dscl . -delete /Users/[yourUserName]
- To Delete a Group
sudo dscl . -delete /Groups/[yourGroupName]
After you are Free to Re-Create User and Group from System Preferences.
If you Re-Create User and Group by System Preferences after you Should Repair Ownerships on Directories and Files Owned by the Deleted Users/Groups.
For example if you deleted and recreated “mysql” User and “mysql” Group after you will need to Recursively set ownership by:
sudo chown -R mysql:mysql /usr/local/mysql
Mac HOW-TO Make a Command Alias 4 Easy-Quick Execution:
How to make a Command Alias as Time-Saver.