Search code examples
osx-mountain-lion

Mountain Lion, export $PATH to .bash_profile, permission denied?


I can do this:

sudo nano .bash_profile

But when I do this:

sudo echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

I get this error message:

-bash: /Users/mycomputer/.bash_profile: Permission denied

When I do ls -al:

-rw-r--r--   1 root         staff     27 10 Aug 12:22 .bash_profile

Solution

  • Quick fix: do "sudo bash", to actually assume root privileges, THEN do the echo. It will work. sudo echo still uses your real uid, so it fails.