Friday 22 March 2019

macos - How to add user to a group from Mac OS X command line?


trying to add a user to a group from the command line but can't figure out how?


Specifically this is on Mac OS X Server 10.5.8


like to add user to 'admin' and 'wheel' groups



Answer



sudo dseditgroup -o edit -a $username_to_add -t user admin
sudo dseditgroup -o edit -a $username_to_add -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.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...