July 25, 2005
.bash_profile vs. .bashrc
One of the things I always have trouble remembering when working with linux is what is the correct ".profile" to edit when I want to automatically set environmental variables and such for my shell.
Included in Debian Woody are both .bash_profile, and .bashrc. I can never remember the difference between these two.
According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.
What I take this to mean is that when I login when using a console, either physically at the machine or using ssh, .bash_profile is executed.
However, if I launch a terminal within a windowing system such as KDE, launch the Emacs *shell* mode, or execute /bin/bash from within another terminal then .bashrc is executed.
At any rate, the point is generally moot because most people edit the files so one calls the other anyway.
To do this under Debian Woody, we open .bash_profile and uncomment the following lines (under the comment # include .bashrc if it exists):
if [ -f ~/.bashrc ]; then source ~/.bashrc fi
Now when we login to our machine from a console, .bashrc will get called. As a bonus, in Debian Woody, the defualt .bashrc turns on coloring when running the ls command. Nice!
Posted by Josh Staiger at 07:13 PM
