Manage Mac user and group accounts from the command line with dscl.

# list all users
dscl . list /users

# list all groups
dscl . list /groups

# list information about each user
dscl . readall /users

# list information about each group
dscl . readall /groups

# add user `root` to group `kmem`
sudo dseditgroup -o edit -a root -t user kmem

# verify user `root` is in group `kmem`
sudo dseditgroup -o checkmember -m root kmem

# remove user `root` from group `kmem`
sudo dseditgroup -o edit -d root -t user kmem