zsh: permission denied: /Users/iprasanna/.bash_profile

I am trying to run the following to set env, but I can not:

echo 'export ethereum_home=/Users/mattthomas/ethereum' >>~/.bash_profile
  • Permissions for .bash_profile:
    -rw-r--r-- 1 root staff 447 Jun 17 21:50 .bash_profile


How can I write to .bash_profile?

2 Answers

Are you executing the command as root, as your file has the following permissions:

-rw-r--r-- 1 root staff 447 Jun 17 21:50 .bash_profile
  • You can write only with user root or you can use sudo with the command, e.g:
    sudo echo 'export ethereum_home=/Users/mattthomas/ethereum' >> ~/.bash_profile

Unless you have root privileges, you can not write to .bash_profile. check to see if your .bash_profile has another profile that it sources from. Run

cat ~/.bash_profile

and look for something like

. ./blah-blah_profile 

or something like that. Usually sysadmins do not let the users mess with the main bash_profile but give them a user defined profile to play with.

It is not uncommon to see something like:

. ~/${USER}_profile

or

. ~/${USER}.rc

etc. pay attention to the space right after the . (dot) character at the beginning of line. That is what "source"s your profile instead of executing it as a script.

If you need further help update your question with the contents of your .bash_profile

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like