How to Delete Users and Groups From Terminal on macOS
Max OS X Deleting Users & Groups by Command Line
Hi! The Mac Tutorial simply Show How to Remove/Delete Users and Groups from the macOS 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.
![How to Delete Users and Groups from Terminal on Mac - Featured](https://tutorialforlinux.com/wp-content/media/dg139/intro/redAppleOnBlackApproved.jpg)
1. Terminal QuickStart
How to Quick-Start with Command Line on macOS:
2. Deleting Users & Groups
So now the Commands to Delete Users and Groups
- To Delete a User
sudo dscl . -delete /Users/[yourUserName]
- To Delete a Group
sudo dscl . -delete /Groups/[yourGroupName]
- To Delete a User
3. Re-Creating Users & Groups
Then in case to Make Users and Groups
To achieve it you can simply use the System Preferences Tool.
And then Fix Ownerships on Directories and Files Owned by the Deleted Users/Groups.
For example if you deleted and recreated “mysql” User and Group after you will need to Recursively Reset 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.