Friday, December 20

bash startup files

I have some settings (such as alias, and PS1) in .bashrc. It is strange that when I open a terminal in GNome, the new terminal works well; but when I use PUTTY to ssh into it, the terminal doesn't have the settings, unless I type "bash" to open a new bash shell.

Note: in /etc/passwd, my account is set to use bash by default. So I am talking about bash only.

This page explains the process: A terminal in GNome is a "non-login shell", and it executes .bashrc directly; A terminal from PUTTY is a "login shell", and it looks for any one file of "~/.bash_profile" or "~/.bash_login" or "~/.profile" (whichever one exists - it only reads one of these, checking for them in the order mentioned). Usually, in that selected one from these 3 files, the last action is to execute .bashrc. That is how the .bashrc got executed indirectly when ssh into the computer in "login shell".

Come back to my case, I am using Ubuntu, which by default has ~/.profile, but not .bash_profile or .bash_login. Somehow there is a .bash_profile in my system which has only one line:
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.6/dist-packages/debug_toolbar

Because of the existence of this .bash_profile file, the .profile file is not loaded, neither is the .bashrc file. After I moved this setting into .profile and deleted .bash_profile, everything is good, .profile and .bashrc are loaded successfully from SSH login.

I am not sure how this file was created: Was it created by python installer automatically? Or was it created by me manually after following some stackoverflow page during the process of installing python? If it is the latter, then it is dangerous to follow the instructions ("put the setting into .bash_profile; if the file doesn't exist,  create one") without know what that means.