Frequently Asked Question

What is the difference between .bashrc, .bash_profile, and .profile?

~/.bash_profile is read by bash when it starts as a login shell, when you sign in at the console, over SSH, or anywhere the login program is involved. Put one-time setup here: PATH additions, exported environment variables, anything that should be set once for the whole session and inherited by every program you launch.

~/.bashrc is read by bash when it starts as an interactive non-login shell; when you open a new terminal tab or run bash from inside another shell. Put aliases, shell functions, prompt customisation, and other interactive niceties here. Things in ~/.bashrc won't be inherited automatically: each new interactive shell re-reads its own copy.

~/.profile is the older, shell-agnostic equivalent of ~/.bash_profile, read by sh, dash, and bash (only if no ~/.bash_profile or ~/.bash_login exists). To avoid duplication, most people put their real config in ~/.bashrc and source it from ~/.bash_profile so both login and non-login shells end up identical. The one-liner [ -f ~/.bashrc ] && source ~/.bashrc at the top of ~/.bash_profile does the job.

Further reading and video