- Debian Admin - http://www.debianadmin.com -

Difference between .bash_profile and .bashrc Files

Posted By Admin On 16th April 2007 @ 21:55 In General | 2 Comments

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

One of the things you always have trouble remembering when working with linux is what is the correct “.profile” to edit when you want to automatically set environmental variables.

According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

when you login when using a console, either physically at the machine or using ssh, .bash_profile is executed.

However, if you launch a terminal within a windowing system such as GNOME,KDE, launch the Emacs *shell* mode, or execute /bin/bash from within another terminal then .bashrc is executed.

Most people edit the files so one calls the other anyway.

To do this you need to 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.

Tags: ,

You may also be interested in...


Article printed from Debian Admin: http://www.debianadmin.com

URL to article: http://www.debianadmin.com/difference-between-bash_profile-and-bashrc-files.html

Click here to print.