Use the following commands to add user to a group:
sudo dseditgroup -o edit -a usernametoadd -t user admin
sudo dseditgroup -o edit -a usernametoadd -t user wheel
It’s also possible to do this with dscl, but to do it properly you need to both add the user’s short name to the group’s GroupMembership
list, and add the user’s GeneratedUID to the group’s GroupMembers
list. dseditgroup
takes care of both in a single operation.