Bash startup scripts or files are used by the shell program /bin/bash to create a shell environment. Each script has a specific use and affects the login environment differently. Every subsequent script executed can override the values assigned by previous scripts.
The startup scripts used by Bash are.
1) ~/.bashrc
2) /etc/bashrc
3) ~/.bash_profile
4) ~/.bash_login
5) ~/.profile
6) /etc/profile
7) /etc/profile.d/*
- User specific startup script.
- Used for setting Local variables, and defining Aliases and Functions.
- Called by the login process, during the creation of both Login shells and Non-Login shells.
- Calls the script /etc/bashrc.
- Global startup script.
- Used for setting Local variables, and defining Aliases and Functions.
- Called by the script ~/.bashrc, during the creation of both Login shells and Non-Login shells.
- Calls the scripts in the directory /etc/profile.d/, in case of Non-Login shells.
- User specific startup script.
- Used for setting Environment variables and running Commands.
- Called by the login process, during the creation of Login shells.
- Calls the script ~/.bashrc.
- User specific startup script.
- Used for setting Environment variables and running Commands.
- Called by the login process, if ~/.bash_profile is not present, during the creation of Login shells.
- Maintained for compatibility with C shell and Tenex C shell startup script, ~/.login.
- User specific startup script.
- Used for setting Environment variables and running Commands.
- Called by the login process, if ~/.bash_profile and subsequently ~/.bash_login are not present, during the creation of Login shells.
- Maintained for compatibility with Bourne shell and Korn shell startup script, ~/.profile.
- Global startup script.
- Used for setting Environment variables and running Commands.
- Called by the login process, during the creation of Login shells.
- Calls the scripts in the directory /etc/profile.d/.
- Directory containing global startup scripts.
- Used for setting Environment variables and running Commands.
- Called by the script /etc/profile, during the creation of Login shells.
Called by the script /etc/bashrc, during the creation of Non-Login shells.
It is recommended to view the following sections also.
Difference between Login shell and Non Login shell
Difference between Local Variables and Environment Variables