If both ~/.bash_profile
and ~/.profile
exist, bash only reads ~/.bash_profile
when it is invoked as an interactive login shell.
https://www.gnu.org/s/bash/manual/html_node/Bash-Startup-Files.html:
Invoked as an interactive login shell, or with --login
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.
[...]
Invoked as an interactive non-login shell
When an interactive shell that is not a login shell is started, Bash reads and executes commands from ~/.bashrc
, if that file exists.
~/.profile
is also used by other shells.
Terminal and iTerm open new shells as login shells by default (by executing something like login -pf $USER
), but many GNU/Linux terminal applications open new shells as non-login shells. OS X users often use ~/.bash_profile
instead of ~/.bashrc
.