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
  1. 1. Terminal QuickStart

    How to Quick-Start with Command Line on macOS:

    Bash Shell macOS QuickStart Guide
  2. 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]
  3. 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
  4. Mac HOW-TO Make a Command Alias 4 Easy-Quick Execution:
    How to make a Command Alias as Time-Saver.

QuickChic Theme • Powered by WordPress