显示所有 user 对应的 group

sudo dscl . -list /groups GroupMembership 

添加 user 到 group

sudo dscl . -append /Groups/groupname GroupMembership username

从 group 中删除 user

sudo dscl . -delete /Groups/groupname GroupMembership username

参考

https://www.jianshu.com/p/865460687bae