View previous topic :: View next topic |
Author |
Message |
Asc n00b
Joined: 07 Feb 2004 Posts: 6
|
Posted: Tue Feb 10, 2004 9:39 am Post subject: bash & .bashrc |
|
|
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 |
|
|
Athas Guru
Joined: 04 Sep 2003 Posts: 394 Location: Brøndby, Denmark
|
Posted: Tue Feb 10, 2004 10:16 am Post subject: |
|
|
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 |
|
|
jrz Apprentice
Joined: 19 Mar 2003 Posts: 272 Location: Sacramento, CA USA
|
Posted: Tue Feb 10, 2004 12:42 pm Post subject: |
|
|
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 |
|
|
|
|
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
|
|