Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash & .bashrc
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Asc
n00b
n00b


Joined: 07 Feb 2004
Posts: 6

PostPosted: Tue Feb 10, 2004 9:39 am    Post subject: bash & .bashrc Reply with quote

I'm a newby to linux and perhaps I try to understand more than neccessary.. but today I had this problem, which I could solve, but don't understand why.


my gentoo installation is quite new and so I habe to configure a lot of basic stuff. and so I edited my .bashrc for the root account to add alias and stuff. I did it also for my user-account.
I noticed, that when I login with my user, the .bashrc is loaded and the aliases are available. when I log in as root, the bash does not load additional configuration. Then I compared both configs and saw, that the .bash_profile file for my root setup was missing. by adding this, login as root worked now properly (well, I had my aliases).

I read in the man, that normaly the .bashrc should be loaded also without the profile file.

well, perhaps someone knows more.. doh.
Back to top
View user's profile Send private message
Athas
Guru
Guru


Joined: 04 Sep 2003
Posts: 394
Location: Brøndby, Denmark

PostPosted: Tue Feb 10, 2004 10:16 am    Post subject: Reply with quote

From man bash:

Quote:
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 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.


So your .bash_profile only gets read when it's a loginshell.

Also, when an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists, so .bashrc will only be read if it's not a loginshell (or if it's specified in your .bash_profile ;) ).
_________________
Emacs-optimized danish console keymap - My .emacs
Climacs - next generation Emacs.
Back to top
View user's profile Send private message
jrz
Apprentice
Apprentice


Joined: 19 Mar 2003
Posts: 272
Location: Sacramento, CA USA

PostPosted: Tue Feb 10, 2004 12:42 pm    Post subject: Reply with quote

i always put aliases and env variables in ~/.bash_profile and at the end of .bash_profile something like this to check if the shell is interactive and if it is to run fortune, which is in .bashrc

Code:

if [ "$PS1" ]; then
   source $HOME/.bashrc
fi

_________________
Press F1 for Help.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum