How do I find my user ID and group in Mac OS X?
On OS X, your primary group is always staff
unless you or your user directory manager changed it.
What's a primary group? The primary group of a user is by default the owner of all files created by that user.
For the purposes of chmod
on your computer, you can use either your numeric user ID (e.g. 501), or your account name (e.g. danielbeck
). The latter is different from the user name you usually see in the UI (e.g. Daniel Beck).
You can determine your account name using any of the following:
It's the name of your home directory (unless you customized it) in Finder's title or side bar
Run
whoami
in Terminal – so achown -R $(whoami):staff
should suffice. You can also get your primary group withgroups $(whoami) | cut -d' ' -f1
.Open System Preferences » Users & Groups, unlock the pane if necessary, right-click your user name (the single list entry in the Current User section), and select Advanced Options…. It's the field Account Name in the newly opened dialog window. This dialog also shows you your primary group.
Run
id
in Terminal for more verbose output. This will include your numeric user ID. It'll also list all groups you're a member of, not just your primary group. The first group is the primary one.
Use the id
command from the terminal. It will display your uid and the groups you belong to. For example,
here is my output showing my user id (534), group id (20) and the groups I belong to
(also 20).
uid=534(galuga) gid=20(staff) groups=20(staff)
This will show your userid.
$ id -u
502
This will show your group names. The group names are inside parentheses.
$ id
uid=502(whoami) gid=20(staff) groups=20(staff),702(com.apple.sharepoint.group.2),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh)