You are on page 1of 2

Bash startup scripts

howtolamp.com/articles/bash-startup-scripts

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/*

1) ~/.bashrc

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.

2) /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.

3) ~/.bash_profile

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.

4) ~/.bash_login

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.

1/2
Maintained for compatibility with C shell and Tenex C shell startup script, ~/.login.

5) ~/.profile

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.

6) /etc/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/.

7) /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.

2/2

You might also like