2010.11.10 17:06
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file/etc/profile, if that file exists. After reading that file, it 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. 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 /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrcand ~/.bashrc.
.profile is for things that are not specifically related to Bash, like environment variables PATH and friends, and should be available anytime. For example,.profile should also be loaded when starting a graphical desktop session..bashrc is for the configuring the interactive Bash usage, like Bash aliases, setting your favorite editor, setting the Bash prompt, etc..bash_profile is for making sure that both the things in .profile and .bashrcare loaded for login shells. For example, .bash_profile could be something simple like. ~/.profile
. ~/.bashrc