You are not logged in.

#1 2008-04-03 01:50:11

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,222
Website

bash shell for root not sourcing .bashrc

Hi all smile

Finally got around to getting my home LAPP server up and running - on Arch of course! smile

Small problem that's really annoying. I can't get root's shell to source the .bashrc file.

I (kind of) followed the colorized prompt tip from the Wiki:
http://wiki.archlinux.org/index.php/Pos … nd_Console

Except I put EVERYTHING in to /etc/bashrc then sym linked my user and root ~/.bashrc to /etc/bashrc:

fukawi2 ~  $ ls -lha .bashrc
lrwxrwxrwx 1 fukawi2 fukawi2 11 2008-04-01 21:53 .bashrc -> /etc/bashrc

And that works fine. Root doesn't though. I tried removing the symlink and replacing it with a 'normal' .bashrc file that only sources /etc/bashrc if it exists:

[root@lapp ~]# cat .bashrc
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

But if I source it manually after I su or sudo, it works fine:

fukawi2 ~  $ sudo -i
[root@lapp ~]#
[root@lapp ~]# (There's no pretty colorized prompt here)
[root@lapp ~]#
[root@lapp ~]# logout
fukawi2 ~  $ su -
Password:
[root@lapp ~]#
[root@lapp ~]#
(Still no pretty prompt!)
[root@lapp ~]#
[root@lapp ~]# logout
fukawi2 ~  $ sudo -i
[root@lapp ~]# . .bashrc
root ~ #
root ~ #  (That's better; now I have the pretty prompt!)
root ~ #

Not having the colors doesn't bother me so much - it's not having all my aliases and not being able to change root's $PATH variable to include /usr/local/bin/ that's really annoying.

Anyone got any advice or suggestions please?

Offline

#2 2008-04-03 01:57:40

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: bash shell for root not sourcing .bashrc

See thread.

Offline

#3 2008-04-03 02:02:36

Pudge
Arch Linux f@h Team Member
Registered: 2006-01-23
Posts: 300

Re: bash shell for root not sourcing .bashrc

Besides having a .bashrc file, you also need a .bash_profile file in root's home directory.  .bash_profile should contain the following:

. $HOME/.bashrc

the .bash_profile file tells bash what file to use for configuration, which by convention has always been .bashrc.

HTH

Pudge

Edit:  Opps, too slow on the trigger.  Brebs beat me to it.  I spent too much time looking in man bash for an explanation of the .bash_profile and .bashrc files.

Last edited by Pudge (2008-04-03 02:04:54)

Offline

#4 2008-04-03 02:56:26

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,222
Website

Re: bash shell for root not sourcing .bashrc

Thanks guys, works beautifully now big_smile

I did Google before asking but couldn't find anything - I should use the forum search too, sorry!

So bash actually sources .bash_profile and it's up to that file to source .bashrc for interactive shells?

Offline

Board footer

Powered by FluxBB