What are bash startup scripts - /etc/profile, ~/.bash_profile, .bash_login, .profile
One place where environment variables are used is in initializing the bash environment upon user login. When a user logs in, several shell scripts are executed to initialize their environment, starting with the /etc/profile, followed by a profile in the user’s home directory, typically ~/.bash_profile.
Because these profiles have additional scripting in them, which calls other shell scripts, the bash login scripting will typically be the following:
/etc/profile \__ /etc/profile.d/*.sh
~/.bash_profile \__ ~/.bashrc \__ /etc/bashrc
Generally, there are two types of login scripts, profiles and “RCs”. Profiles are for setting and exporting environment variables, as well as running commands that should only be run upon login. RCs, such as /etc/bashrc, are for running commands, setting aliases, defining functions, and other settings that cannot be exported to sub-shells. Usually, profiles are only executed in a login shell, whereas RCs are executed every time a shell is created, login or non-login.
The layout of the file call is such that a user can override the default settings provided by the system-wide scripts. Many of the configuration files provided by Red Hat will contain a comment indicating where user-specific changes should be added.