Yes, that is the expected behaviour.
The behaviour, in short, is as follows:
- bash started as an interactive login shell: reads
- bash started as an interactive non-login shell: reads
Read the bash manual about startup files for more details.
Personally, I think that this behaviour is strange and I have not yet found a rationalization for this design decision.
Some explanation for the terminology: an interactive shell is a shell with which you can interact, that means you can type commands in it. A non-interactive shell is a shell with which you cannot interact. Non-interactive shells are usually started to run shell scripts.
A login shell is a shell which is started when you login to your system, or when you start bash using the
--login option. A non-login shell is a shell which is started after the login process, and without the
--login option. Configuring gnome-terminal to start bash as a login shell means it will start bash using the
Most shells you see are interactive non-login shells. This is especially true if you are running a graphical shell like gnome, because then gnome is the login shell. Any bash session started inside gnome is a non-login shell (unles started using
--login). If you want to see a real interactive login shell then go to a virtual console (using
Ctrl+Alt+F1) and then log in using your username and password. That is a real interactive login bash shell. You can go back to the graphical shell using
Usually you want bash to always read
~/.bashrc. Here is how I recommend to do that:
~/.bash_profile file. If bash is started as a login shell it will first look for
~/.bash_profile before looking for
~/.profile. If bash finds
~/.bash_profile then it will not read
Put the following lines in
[ -f "$HOME/.profile" ] && source "$HOME/.profile"
[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"
Now if bash is started as an interactive login shell it will read the following files:
and if bash is started as an interactive non-login shell:
You should put stuff which is bash specific in
~/.bashrc and stuff which is not bash specific in
~/.profile. For example
PATH goes in
HISTCONTROL goes in
~/.profile is not bash specific. Other text based shells (for example sh or ksh) and graphical shells (gnome) also read
~/.profile. That is why you should not put bash specific stuff in