So I am using CentOS 6.3 a fresh install and I was trying to add things to my path for OpenMPI so I edited my .bash_profile file to read:

export FOO

# Add support for MPI

# User specific environment and startup programs


export PATH

Which apparently isn't being read when I start up a bash shell, my $PATH is without the /usr/lib64/openmpi/bin path and FOO doesn't exist when I try to echo $FOO

.bashrc is read just fine and if I do source ~/.bash_profile FOO is created as well as my $PATH being edited properly but it will not run .bash_profile on its own so if I could get any help that would be great.


Could you describe how do you test these 2 files? Did you try login or non-login shell? Here is the difference:

When you login your system and see the command line prompt, it’s a login shell, and it executes these files in order:


A non-login shell will only execute the two files in order:


If you just simply start a bash shell by "bash", it is a non-login shell and ~/.bash_profile will not be invoked. If you expect the variables to be set even when running non-login shell, you should put them into ~/.bashrc.

| improve this answer | |
  • It doesn't execute .bashrc if .bash_profile doesn't say so. On my system, for my account, .bash_profile didn't exist, so .bashrc was never executed. – SPRBRN May 26 '15 at 12:40

This is normal, .bash_profile is sourced for login shells, .bashrc is sourced for interactive non-login shells. In CentOS the top of .bash_profile usually has:

if [ -f ~/.bashrc ]; then
    . ~/.bashrc

So you can put things in .bashrc.

Mac OS X Terminal reads .bash_profile when you open a new windows. gnome-terminal can be made to do that with Run command as a login shell.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.