Apple - Understanding the 'staff' user group

There's only one reliable way to get all members of a group in OS X and the reply from 2DD8847 covers that. As for "why" I can't offer a logical explanation. All I can tell you is what differentiates the results.

These approaches fail to include users that are only members of the group via PrimaryGroupID. One way to think of it is that these users not listed weren't officially added to the staff group. They were just given a PrimaryGroupID that matches the staff gid. Therefore they're not officially listed with some commands. I know, it's absurd.


dscl . -read /Groups/[groupname]
dscl . -read /Groups/[groupname] GroupMembership
dscacheutil -q group -a name [groupname]


dscl . -list /Users PrimaryGroupID | grep [gid]

All I can really tell you is that without looking up group members by their PrimaryGroupID (instead of listing members of a group) it won't give you complete results. Chalk it up to the oddities of Unix. There are many.

Hope that helps!


What exactly do you want to achieve/do?

This command lists all users in the staff group:

dscl . -list /Users PrimaryGroupID | grep ' 20$'


Explanation: The staff group has the PrimaryGroupID of 20.