Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With Linux/Unix, I can use useradd -G developers vivek to add vivek to the developer group. How can I do the same thing with Mac OS X?

Then, how do I check if vivek is in developers group?

share|improve this question
possible duplicate of Can user accounts be managed via the command line? – user588 Apr 29 '11 at 4:32
up vote 10 down vote accepted

I've used this one-liner:

sudo dscl localhost -append /Local/Default/Groups/thegroupname GroupMembership theusername
share|improve this answer

To add a user to a group:

dseditgroup -o edit -a vivek -t user developers

(Note: you can also do this with dscl as in @hobs' answer, but you really should both add the user's short name to the GroupMembership list, and also add the user's GeneratedUID to the GroupMembers list. dseditgroup does both with a single operation.)

To check membership:

dseditgroup -o checkmember -m vivek developers


dsmemberutil checkmembership -U vivek -G developers

To remove a user from a group:

dseditgroup -o edit -d vivek -t user developers

(Again, you can do this with dscl, but need to remove the user from both GroupMembership and GroupMembers. dseditgroup does both.)

share|improve this answer
Confirmed. dscl only adds without checking user is in group already. it just adds. & it may create duplicate membership for the same user on group. – risyasin Apr 10 '15 at 7:38

Two ways: From the terminal

Everything here should be done on the command line First start dscl like this:

$ dscl localhost

Then cd to the Groups node:

cd /Local/Default/Groups

You can see all the groups using ls. Once you have found the group you are interested in, you can view all its properties with cat groupname. When you are ready to add a user (username) to the group (groupname), use the following command:

append groupname GroupMembership username

If you want to remove a member from a group, use the following command (be careful!):

delete groupname GroupMembership username

When you are finished with your changes, exit dscl by typing exit.

And the apple official way:

Choose Apple menu > System Preferences, and then click Accounts. Open Accounts preferences Step 2

If the preferences pane is locked, click the lock icon and enter an administrator name and password. Step 3

Click the Add (+) button, located below the list of accounts, to create a new account. Step 4

Select a Group from the New Account pop-up menu. Step 5

Enter a name for the group, and then click Create Group. Step 6

Select the checkboxes by the accounts to be members in the group.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.