Ever wondered about the difference between
/etc/bash.bashrc (and maybe others)
and what their purposes are? I do.
Some interesting excerpts from the bash manpage:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the
--loginoption, it first reads and executes commands from the file
/etc/profile, if that file exists. After reading that file, it looks for
~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The
--noprofileoption may be used when the shell is started to inhibit this behavior.
When an interactive shell that is not a login shell is started, bash reads and executes commands from
~/.bashrc, if these files exist. This may be inhibited by using the
--rcfilefile option will force bash to read and execute commands from file instead of
As far as I understand, a login shell means a session where you log in to the system and directly end up in Bash, like a remote ssh session or logging in through a non-graphical text terminal. A non-login shell is then the type of shells you open after logging in: typically in a graphical session when you open a new terminal window.
How I think things are supposed to work (for a typical setup):
.profileis for things that are not specifically related to Bash, like environment variables
PATHand friends, and should be available anytime. For example,
.profileshould also be loaded when starting a graphical desktop session.
.bashrcis for the configuring the interactive Bash usage, like Bash aliases, setting your favorite editor, setting the Bash prompt, etc.
.bash_profileis for making sure that both the things in
.bashrcare loaded for login shells. For example,
.bash_profilecould be something simple like
. ~/.profile . ~/.bashrc
As stated in the man page excerpt above, if you would omit
.profilewould be loaded.
You might also be interested in the page I put together with the most important stuff from my
.profile and other files.