bash login scripts

order of script execution of bash login scripts:

for an interactive login shell or when invoked as /bin/sh, bash executes /etc/profile then the first found of:

~/.bash_profile, ~/.bash_login, ~/.profile

in that order. if a login shell, the environment variable login_shell will be set.

for an interactive non-login shell eg., an xterm, only ~/.bashrc is sourced if it exists, and if ENV is set, its file is sourced. if an interactive shell, the environment variable $- will contain a lower-case "i".

if started non-interactively, bash looks for the environment variable BASH_ENV for the name of a file to execute.

remote ssh commands are considered non-login, interactive shells.

updated: Wed May 5 10:23:25 PDT 2010