Changing Ownership of a directory in OS X

36,192

Solution 1

On my system, /usr/local is owned by root:admin and is rwxrwxr-x. My user is a member of the admin group, thus has write permissions. I haven't messed with ownership and permissions there, and my Homebrew installation is not complaining, so I assume my setup fits its requirements.

Check the ownership of your /usr/local; if it is owned by group admin, check if your non-adminsitrator account is a member of that group.

Solution 2

Simple solution that worked for me:

  1. click on your background to go to finder
  2. click on go and go to folder /usr
  3. right click on local and do get info
  4. unlock the lock at the bottom
  5. click + sign and add your user to the list and give read/write privileges
  6. click on the gear sign at the bottom and choose apply to enclosed items to recurse under that directory and assign privileges too all directories beneath it.

type brew doctor from command prompt to test. My result:

Your system is ready to brew.

Solution 3

You should use: sudo chown username folder

Solution 4

Be careful with the change of ownership

Do not try to change ownership for /usr/ or recursively for /usr/local/ if you are not getting the same error posted in the original question.
You could screw up your system or weakness its security.

Some users can receive with homebrew permission errors that could be solved without changing the ownership of the whole /usr/ or /usr/local/ directories.

According to my experience, in most cases, it is just enough to restore the ownership for /usr/local/Cellar:

sudo chown -R "$USER" /usr/local/Cellar/

Alternatively, if you have a not standard installation

sudo chown -R "$USER" "$(brew --prefix)/Cellar"
Share:
36,192
Graeme
Author by

Graeme

I'm an LSAT tutor in Montreal. I'm learning programming, because I think it will be very useful for my LSAT website. I'm following this method, recommended by Joel. Many people replied that the method looked "hard". I looked at it and thought "I could do that in three months?". I had previously viewed K & R and SICP as books for experts. I started reading code Christmas 2011. As of February 2012, I'm on the pointers chapter of K & R. I highly recommend Code and K & R for anyone learning programming. It was slow going at first, but I'm going faster as I pick up more peripheral knowledge. You start knowing nothing, but each new thing you learn makes further learning easier. I'm now able to read the reference section at the back, which is really helping clarify sticking points. I've only asked a couple of questions here so far, but I've been impressed by the speed, clarity and friendliness of the answers. I hope to learn enough to contribute, eventually.

Updated on July 27, 2020

Comments

  • Graeme
    Graeme almost 4 years

    I've installed homebrew, and am trying to change the write permissisons for the /usr/local/include directory.

    When I run 'brew doctor', I get this error message:

    Error: The /usr/local directory is not writable. Even if this directory was writable when you installed Homebrew, other software may change permissions on this directory. Some versions of the "InstantOn" component of Airfoil are known to do this.

    You should probably change the ownership and permissions of /usr/local back to your user account.

    I tried doing that with chown, but I'm pretty new at this and don't think I was running it correctly. I ran:

    chown myusername /usr/local/include
    

    I didn't get any error message, but when I run brew doctor it says I still lack permission to write to /usr/local/include.

    Any help would be greatly appreciated!

    Edit:

    I'm getting an "operation not permitted" error.

    cd /usr

    chown myusername local

    chown: local: Operation not permitted