48

Trying to run this compand in terminal:

sudo chown -R yourid:yourgroup local

However, I have no idea what my ID and my group are, or where to find them. Any ideas?

57

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 a chown -R $(whoami):staff should suffice. You can also get your primary group with groups $(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.

  • 3
    Instead of using whoami, you can use id in a oneliner that is compatible with posix shells and csh. chown -R `id -u`:`id -g` FOLDER – fd0 Jul 4 '15 at 10:18
  • If you use LDAP authentication your username won't necessarily be staff. Not on my work Mac OS X anyway. – Sridhar-Sarnobat Jul 31 '15 at 23:21
  • 1
    @Sridhar-Sarnobat I address this in the second half of the first sentence of my answer. – Daniel Beck Aug 1 '15 at 10:28
37

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)
11

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)
3

in Terminal, go to ~/Documents and run ls -la. Your user name and group will be listed next to each of the files/directories.

It should look like this:

drwxr-xr-x  2 username usergroup  4096 Oct 17  2012 Templates
  • super easy and straightforward, thanks for the tip. – teradyl Oct 26 '16 at 23:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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