If .bash_profile exists, then Bash will not read .bash_login (or .profile). This annoying feature is described in some versions of the Bash manual, but not all.
.bash_profile
and .bash_login
are analogous, so I recommend you put your commands in .bash_profile
, because it's is commonly used and .bash_login
is relatively unknown. Also consider putting your commands in .bashrc
instead of .bash_profile
. The manual describes difference between "interactive non-login shell" and "interactive login shell", so be sure to read that section.
The GNU Bash Reference Manual version 4.1: Bash Startup Files says:
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.
Also see this question on superuser, and this Bash howto (Don't be deterred by the freeunix.dyndns.org:8088 address--- it's still a good quality manual and I have used it for years).
Update, since you say you don't have a .bash_profile.
It sounds like you are not using what's called a "interactive non-login shell" (See the Bash manual for a detailed description).
To test this, add something like the following each file: .bashrc
, .bash_profile
and .bash_login
.
echo "DEBUG: I am .bashrc"
echo "DEBUG: I am .bash_profile"
Then log out and log in again. When you log in, I bet you will only see the phrase "DEBUG: I am .bashrc" but not "I am .bash_profile". If so, it means you are a "interactive non-login shell", which simply means that Bash will call .bashrc
but not .bash_profile
. For information why these dotfiles are the way they are, see @Andrejs Cainikovs's post below and http://mywiki.wooledge.org/DotFiles
~/.bash_profile
?-rw-r--r-- 1 gsd gsd 313 2012-01-22 11:56 .bash_login
chmod +x .bash_login
chmod +x .bash_login
(set the executable bit on .bash_login). The Bash manual is a bit confusing in this area, but Bash does not eXecute .bash_login like a shell script. It does read the file and then executes the commands within it (You can do something similar by runningsource ~/.bash_login
).