Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an administrator account on my OS X Lion 10.7.2. I have installed a few applications through this account, but I am not able to run them without sudo. For example, I installed git and I cannot just simply run git from the terminal as I get

-bash: git: command not found

Instead I need to run sudo git.

I have similar issues with other applications. Another one that is not working is MacFusion.app that tries to use /Applications/Macfusion.app/Contents/PlugIns/sshfs.mfplugin/Contents/Resources/sshfs-static. I tried running sshfs-static from the terminal, but once again I had to sudo to make it work.

Any suggestions?

share|improve this question
    
I used git-osx-installer that I downloaded from code.google.com/p/git-osx-installer/downloads/list?can=3 . I checked my PATH and /usr/local/git/bin is in it. – liutikas Mar 20 '12 at 13:14
    
I checked my path without sudo. I did echo $PATH – liutikas Mar 20 '12 at 13:22
    
Add PATH=/usr/local/git/bin:$PATH to your ~/.bash_profile and check that the git binary file has correct permissions (execute set). – slhck Mar 20 '12 at 13:26
    
I just found out that I cannot even ls /usr/local without sudo. How do I fix that? All the directories there have been set to root as user and wheel as group. – liutikas Mar 20 '12 at 13:31
    
Then try sudo chown -R $(whoami) /usr/local. It's not a system folder anyway, so it's better to keep it owned by you. – slhck Mar 20 '12 at 13:34
up vote 9 down vote accepted

/usr/local is not used on a default installation of OS X and typically is owned by your user, since you will create it and populate it. The popular package manager Homebrew will set the permissions and use it without ever needing root permissions.

If it's owned by root, and missing execute/read permissions for your user, then the commands in /usr/local/bin (or /usr/local/git/bin) will only work when called with sudo.

To fix this, take ownership of /usr/local again:

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

As for why this happened, I can only guess that the git-osx-installer reset the permissions of /usr/local to something more restrictive. Some bug reports mention that.

share|improve this answer
    
can you please explain what does $(whoami) mean? – Samir Sabri Aug 29 '15 at 11:47
1  
@SamirSabri The whoami command returns your username. When you wrap a command in $(), its output is replaced on the commandline. This is called command substitution. Thus, for example, when I type echo $(whoami), it runs echo slhck. – slhck Aug 29 '15 at 12:28
    
Thanks for explination – Samir Sabri Aug 30 '15 at 17:41

You must log in to answer this question.

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