Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

FOO='test'
export FOO

# Add support for MPI
PATH=$PATH:/usr/lib64/openmpi/bin

# User specific environment and startup programs

PATH=$PATH:$HOME/bin




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.

share|improve this question
add comment

2 Answers

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:

/etc/profile
~/.bash_profile
~/.bashrc
/etc/bashrc

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

/etc/bashrc
~/.bashrc

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.

share|improve this answer
add comment

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
fi

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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