Skip to content
Blog Execution Sequence of .bash_* files

Execution Sequence of .bash_* files

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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.