bash troubles
Michal Moskal
malekith at pld-linux.org
Tue Nov 5 14:25:04 CET 2002
On Tue, Nov 05, 2002 at 02:14:08PM +0100, lubos klokner wrote:
> hello,
>
> i'm using bash as shell for user root.
> there is problem with /etc/bashrc and ~/.bashrc when i use "su -"
> command. everything in these files is ignored, but when i use "su"
> to change user to root, everything works fine and all aliases,
> variables... are correctly loaded.
>
> can you help me please ?
From man bash:
When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands 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.
[snip]
When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.
Therfore login shell (as started with su -) will not read bashrc file.
You can overcome it by inserting . /etc/bashrc to /etc/profile (in bash
section), or . ~/.bashrc in ~/.bash_profile. In fact standard rc file
from PLD skel does it:
#v+
# .bash_profile - file executed when logging in
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
#v-
--
: Michal Moskal ::::: malekith/at/pld-linux.org : GCS {C,UL}++++$ a? !tv
: PLD Linux ::::::: Wroclaw University, CS Dept : {E-,w}-- {b++,e}>+++ h
More information about the pld-users-en
mailing list