Global bash_profile
It's not called bash_profile
, but the standard place for global bash configuration is /etc/bash.bashrc
. It's usual to call this from /etc/profile
if the shell is bash. For example, in my /etc/profile
I have:
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1=’0
if [ ‐f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
fi
fi
In terms of usage, /etc/profile
provides system-wide configuration for all Bourne compatible shells (sh, bash, ksh, etc.). There's normally no need for an equivalent /etc/bash_profile
, because the intention of the profile file is to control behaviour for login shells. Normally anything you want to do there is not going to be bash-specific. /etc/bash.bashrc
is bash-specific, and will be run for both login and non-login shells.
To further complicate things, it looks like OS X doesn't even have an /etc/bash.bashrc
. This is probably related to the fact that Terminals in OS X default to running as login shells, so the distinction is lost:
An exception to the terminal window guidelines is Mac OS X’s Terminal.app, which runs a login shell by default for each new terminal window, calling .bash_profile instead of .bashrc. Other GUI terminal emulators may do the same, but most tend not to.
I don't run OS X, so the extent of my knowledge ends there.
/etc/profile
is the global bash_profile
. There's no file that's specific to bash, bash just reads the standard file read by all Bourne-style shell. That's where you can set system-wide environment variables.
See Is there a ".bashrc" equivalent file read by all shells? for a generic overview of bash's common startup files.