Execution Sequence of .bash_* files
What is the sequence in which the following files are executed?
Execution sequence for interactive login shell
Following pseudo code explains the sequence of execution of these files.
IF ~/.bash_profile exists THEN
IF ~/.bash_login exist THEN
IF ~/.profile exist THEN
When you logout of the interactive shell, following is the sequence of execution:
IF ~/.bash_logout exists THEN
Please note that /etc/bashrc is executed by ~/.bashrc as shown below:
# cat ~/.bashrc
if [ -f /etc/bashrc ]; then
Execution sequence for interactive non-login shell
While launching a non-login interactive shell, following is the sequence of execution:
IF ~/.bashrc exists THEN
Note: When a non-interactive shell starts up, it looks for ENV environment variable, and executes the file-name value mentioned in the ENV variable.