11

From the terminal, I tried to go to usr\local\bin under my user name login id, but I got the Permission denied. Same as ls command. Any suggestions?

Edit:

mac1:/ user1$ ls -la /usr/local

total 0

drwxr-xr-x   5 root  wheel  170 Feb 15 17:53 .

drwxr-xr-x@ 12 root  wheel  408 Jan 16 14:30 ..

drwx------  19 504   wheel  646 Feb 15 18:39 bin

drwxrwxr-x   4 root  admin  136 Dec 16 08:47 lib

drwxr-xr-x   6 root  wheel  204 Feb 15 17:53 share
  • Can you please show us the output of ls -la /usr/local? – slhck Feb 16 '14 at 16:30
  • @slhck: Please the edit. – EmilyJ Feb 16 '14 at 16:40
27

In versions of OS X or macOS previous to High Sierra (10.13), you could just type:

sudo chown -R $(whoami) /usr/local

This does not apply to macOS 10.13 or above, as System Integrity Protection will ensure the ownership of /usr/local cannot be changed.

Or if you want it specific to /usr/local/bin:

sudo chown -R $(whoami) /usr/local/bin

Also, your permission modes are off—ideally /usr/local/bin should be accessible by others too:

sudo chmod -R u=rwX,go=rX /usr/local/bin
  • 10
    I don't generally recommend using numeric modes (like 755) with recursive changes -- it's likely to add execute access to plain files that shouldn't be executable (although in the case of a bin directory it's probably not a problem). Instead use something like sudo chmod -R u=rwX,go=rX /usr/local/bin -- the "X" mode sets execute access only if it looks appropriate. – Gordon Davisson Feb 16 '14 at 17:49
  • Good suggestion, thank you. Like you said, I only wrote this because we were talking about a bin directory. – slhck Feb 16 '14 at 21:16
  • Not really a good idea. This might change the owner of binaries which could stall process and give you a hard time. Better selectively "own" single binaries that you need. – kaiser Nov 6 '16 at 20:11
  • Talking about how this happens, it looks like macport for instance creates this status. At least it created it on my mac. drwx------ 29 macports wheel 986B 8 Aug 14:01 bin – oscaroscar Aug 8 '17 at 12:16
  • 1
    I am getting the below error when doing so (I have tried with and without sudo): chown: changing ownership of '/usr/local/bin/docker-compose': Operation not permitted – fuddin Sep 27 '18 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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