7.2.2. Shell setup files
When entering the ls -al command to get a long listing of all files,
including the ones starting with a dot, in your home directory, you
will see one or more files starting with a . and ending in
rc. For the case of bash, this is
.bashrc. This is the counterpart of the
system-wide configuration file /etc/bashrc.
When logging into an interactive login shell, login will do the authentication, set the environment
and start your shell. In the case of bash,
the next step is reading the general profile from /etc, if
that file exists. bash then looks for
~/.bash_profile, ~/.bash_login and ~/.profile, in that order, and reads and executes
commands from the first one that exists and is readable. If none
exists, /etc/bashrc is applied.
When a login shell exits, bash reads and
executes commands from the file ~/.bash_logout, if it exists.
This procedure is explained in detail in the login and bash man pages.