One advantage to using the optional script name ~/.bash_login
, rather than ~/.profile
, is that there is a parallel name for your logout script, ~/.bash_logout
, if you decide to use it.
So if you're running Bash, rather than Bourne, this simplifies the configuration name set complexity from this:
/etc/profile # system login script
~/.bash_profile # user login script
~/.bash_logout # user logout script
/etc/bash.bashrc # system interactive script
~/.bashrc # user interactive script
to this:
/etc/profile # system login script
~/.bash_login # user login script <--sisters +
~/.bash_logout # user logout script <----------+
/etc/bash.bashrc # system interactive script
~/.bashrc # user interactive script
However, if you don't intend to use a logout script, this other way might be simpler for you:
/etc/profile # system login script
~/.bash_profile # user login script
/etc/bash.bashrc # system interactive script
~/.bashrc # user interactive script
Too bad there isn't more name symmetry in the config names...
But you might make this somewhat better with these symbolic links:
/etc/bash --> /etc/profile # system login script
~/.bash --> ~/.bash_profile # user login script
/etc/bashrc --> /etc/bash.bashrc # system interactive script
~/.bashrc # user interactive script
Non-destructively created with:
sudo ln -sT /etc/profile /etc/bash
ln -sT ~/.bash_profile ~/.bash
sudo ln -sT /etc/bash.bashrc /etc/bashrc
# ~/.bashrc (don't change)
Or you can get more aggressive and reverse this, and move the files to the new names, and instead back-link them:
sudo mv -f /etc/profile /etc/bash && \
sudo ln -sT /etc/bash /etc/profile
sudo mv -f /etc/bash.bashrc /etc/bashrc && \
sudo ln -sT /etc/bashrc /etc/bash.bashrc
mv -f ~/.bash_profile ~/.bash && \
ln -sT ~/.bash ~/.bash_profile
# ~/.bashrc (don't change)
Either way, now you have these more uniform config file names, easily found when you forget them from their links:
/etc/bash # system login config script
~/.bash # user login config script
/etc/bashrc # system interactive config script
~/.bashrc # user interactive config script
(I don't use a logout script, but it would probably be named: /etc/bash.logout
.)
~/.bash_login
help with that.bash_login
is explained in the manpage as"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"