Bash’s startup configuration file can help us pre-load some other script files as well as preset general and necessary variables.

Bash provides two types of startup files, one that is loaded on login and the other that is loaded on non-login.

Login Shell Startup Files

The startup files that will be loaded at login are:

Global

1
cat /etc/profile    # Global startup file, Debian(Ubuntu) and Redhat(CentOS) distributions
img

Prints a partial content of the /etc/profile on CentOS 7 distribution

img

Prints a partial content of the /etc/profile on Ubuntu 18 distribution

User Specific

1
cat ~/.bash_profile    # RedHat(CentOS) distributions
img

Prints the content of the ~/.bash_profile on CentOS 7 distribution

1
cat ~/.profile    # Debian(Ubuntu) distributions
img

Prints the content of the ~/.profile on Ubuntu 18 distribution

1
cat ~/.bash_login    # Debian(Ubuntu) and RedHat(CentOS) distributions

Non-login Shell Startup Files

The boot files that will be loaded when you enter a bash shell are:

1
cat /etc/bashrc    # Redhat(CentOS) distributions
img

Prints a partial content of the /etc/bashrc on CentOS 7 distribution

1
cat ~/.bashrc    # Debian(Ubuntu) and RedHat(CentOS) distributions
img

Prints the content of the ~/.bashrc on CentOS 7 distribution

img

Prints a partial content of the ~/.bashrc on Ubuntu 18 distribution

References 6 Bash Features, 6.2 Bash Startup Files

Buy me a coffeeBuy me a coffee