The profile is usually run on each login. The system-wide login file is
/etc/profile and the user-specific files are usually
~/.profile. Some shells have their own profile and rc files, for example bash has
.bashrc which is run by non-login bash shells and
.bash_profile which is run by login bash shells. The system-wide bashrc is
Thus, you would use
.profile for things that should be run by login shells and
.bashrc (or an equivalent) for things that should be run by non-login shells (aliases, setting up the env and similar)
There are two kinds of shells: login and non-login shells. A login shell is the shell run when a user logs in. Non-login shells are all other shells. For example, when you log in via
ssh or on a console, the shell you get is a login shell.
bash login shells run at startup:
- The first existent file of the following:
bash non-login interactive shells run at startup:
In some (most?) unices that come with bash, the profile sources
~/.bashrc is run for both login and non-login interactive shells.
If a file does not exist it is skipped.