Systemwide .bash_profile file

bash

The order of directories in my path is messed up, and I'm trying to correct it. Some of the path seems to be coming in from somewhere other than my user bash config files (I'm using both .bashrc and .bash_profile).

Is there a system wide bash_profile (or other config files?) file which is executed before user specific ones? If so, where is it located by default?

Best Answer

The answer seems to be yes.

Check out the FILE section of Bash Man page

FILES
   /bin/bash
          The bash executable
   /etc/profile
          The systemwide initialization file, executed for login shells
   ~/.bash_profile
          The personal initialization file, executed for login shells
   ~/.bashrc
          The individual per-interactive-shell startup file
   ~/.bash_logout
          The individual login shell cleanup file, executed when a login shell exits
   ~/.inputrc
          Individual readline initialization file

In addition to that, shell paths are also loaded from /etc/paths and the files (if any) in /etc/paths.d by /usr/libexec/path_helper (which is executed as part of /etc/profile).

Lastly, there's also /etc/bashrc, intended for functions and aliases (while /etc/profile is designated for system wide environment and startup programs).