Manage User Group in Mac

List all users

dscl . list /users
dscl . readall /users

List all groups

dscl . list /groups
dscl . readall /groups

Check members under a group

members () { dscl . -list /Users | while read user; do printf "$user "; dsmemberutil checkmembership -U "$user" -G "$*"; done | grep "is a member" | cut -d " " -f 1; };
members $group_name_you_want_to_check

Check groups a user belongs to

groups $user_name

Add user to a group

sudo dseditgroup -o edit -a $user_name_to_add -t user $group_want_add


电子邮件地址不会被公开。 必填项已用*标注