22

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
2
  • Can you please show us the output of ls -la /usr/local?
    – slhck
    Feb 16, 2014 at 16:30
  • @slhck: Please the edit.
    – EmilyJ
    Feb 16, 2014 at 16:40

2 Answers 2

40

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
6
  • 11
    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. Feb 16, 2014 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, 2014 at 21:16
  • 1
    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, 2016 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, 2017 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
    – user46959
    Sep 27, 2018 at 14:23
0

I simply placed cd (change directory) in front of /usr/local/bin and it joshuafranklin@Joshuas-MBP bin % First time using mac to run python

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .