You are not logged in.
A lot of books and manuals say that a login shell reads /etc/profile and ~/.bash_profile upon startup .
see:http://www.linuxfromscratch.org/blfs/vi … ofile.html
I add NAME = "tom" to ~/.bashrc ,save and exit . when I login again ,I get a login shell right ? I type echo $NAME
,then I see the output is tom. It means a login shell also reads ~/.bashrc /etc/bashrc . Is that right ?
Last edited by lovat (2008-01-25 14:53:21)
Do not use Linux as desktop.
Offline
yes .... if you add to .bashrc [user] it will load at boot.... or you can use source ~/.bashrc
There is a thread on bashrc on forum you may want to look at too
Mr Green
Offline
Try calling it with --login and without.
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
Generally, having your .bash_profile say source ~/.bashrc removes any confusion.
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, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be
used when the shell is started to inhibit this behavior.
Offline
It seems logical to me that .bashrc is sourced by any bash shell, .bash_profile only by login shells.
Offline
It seems logical to me that .bashrc is sourced by any bash shell, .bash_profile only by login shells.
Don't forget non-interactive shells. They don't read anything by default as it should be.
Offline
try
export NAME="tom"
instead. 'export' allows that variable to be 'exported' to the current shell and all those spawned from it.
Normally .bash_profile calls on .bashrc which normally calls on /etc/bash/bashrc which is where it gets all its important system variables plus any extras you define in it.
Offline