I know this is a pretty old post, but this problem comes and goes quite oftenly and a lot of laborous solutions are offered. The fact is: being aware of a simple info would solve this pretty fast and easy:
LINUX/Unix OS will load the profile files on startup following the rules below (some distros may have other files names, mainly for user local profiles, but the main rule follows this):
- Login Shell
First and foremost: /etc/profile
is loaded (global settings);
Next: ˜/.bash_profile
(local user settings- other files may be found, like ˜/.profile
, depending on the distro. Check documentation).
So, if you are in a Login Shell environment, put all your crazy stuff inside ˜/.bash_profile
(or the file provided by your distro) and everything will be fine.
- Non-login Shell
First and foremost: /etc/bashrc
(some distros will load bash.bashrc
);
The next file to be seeked and loaded is ˜/.bashrc
And that's why so many people (just like me) got frustrated having to source their ˜/.bash_profile
every single time a Terminal was loaded. We were simply inserting info in the "wrong" file- regarding the kind of shell loaded (see above: login, non-login).
More details on variants of the files mentioned above and some info on login vs non-login shell can be found here.
Hope it helps \o/