Execution Sequence of .bash_* files

On March 15, 2010, in bash, Sequence, by Dipin Krishna

Execution sequence for interactive login shell
execute /etc/profile

IF ~/.bash_profile exists THEN
execute ~/.bash_profile
ELSE
IF ~/.bash_login exist THEN
execute ~/.bash_login
ELSE
IF ~/.profile exist THEN
execute ~/.profile
END IF
END IF
END IF

When you logout of the interactive shell, following is the sequence of
execution:

IF ~/.bash_logout exists THEN
execute ~/.bash_logout
END IF

Please note that /etc/bashrc is executed by ~/.bashrc as shown below:

# cat ~/.bashrc
if [ -f /etc/bashrc ]; then
. /etc/bashrc
Fi

Execution sequence for interactive non-login shell
While launching a non-login interactive shell, following is the sequence of
execution:

IF ~/.bashrc exists THEN
execute ~/.bashrc
END IF
 

Leave a Reply

*

Search