I work on an AIX system where I have no administrator privileges. It has several shells installed, default being tcsh. I am not allowed to change the login shell. Usually I start my session from exec bash. The problem is that I do not inherit the $PATH I had in tsch. The first strange thing is that some of the entries in my $PATH are duplicated, when I do exec bash. Another strange thing is that when I do exec bash --norc and then source .bashrc everything is fine -- I get the path from tcsh and some additions from my .bashrc.

I have tried commenting out my .bashrc enirely, but it gave no result -- I still do not get the $PATH from tcsh. It seems that the system wide /etc/profile is manipulating my $PATH. I tried running exec bash --noprofile, but I still see the changes, that are introduced by /etc/profile script (which I have no control over).

So in the end perhaps someone spotted a flaw in my investigation and can tell me how to invoke bash with inhereted $PATH or can suggest a way to do it without reading the global config scripts?

(I have posted this question on superuser as well, I am not sure if it is ok, to duplicate questions, but I got no answer there, so what a heck...)


1 Answer 1


If doing source .bashrc gives you the environment you want, then what you are missing is an interactive login shell. To make bash work in that way, simply run exec bash --login or short exec bash -l.

  • Didn't do anything new. I login to my box, do some changes to my $PATH, then do exec bash --login and loose the my $PATH that was available in tcsh. Dec 8, 2011 at 10:36
  • Hm, so is it different from what you get after doing exec bash --norc + source .bashrc (as you've described)? Dec 8, 2011 at 15:14
  • How about the same thing without exec? (that is, run just bash -l) Dec 8, 2011 at 15:17
  • 1
    exec bash --norc + source .bashrc is different from exec bash --login and exec bash --noprofile. Leaving exec out does not change anything. The other environment variables are not changed. If I setenv v hi in tcsh, then I can see it when I do echo $v in bash whichever way it was invoked it. So it is something that manipulates the environment. In man bash (as far as I read) several scripts are listed as a startup sequence (for a login shell however): /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile. Out of those only /etc/profile exists on my system. Dec 8, 2011 at 17:32
  • "(...) /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile. Out of those only /etc/profile exists on my system." - This means you need to create ~/.bash_profile and put [[ -f ~/.bashrc ]] && . ~/.bashrc in it. If that doesn't solve it, I will have to delete my answer as irrelevant. Dec 9, 2011 at 14:49

You must log in to answer this question.

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