These descriptions are based on my experiences with a variety of Debian & Fedora based environments - each has their own peculiarities in their implementation of bash. I'll do my best to be "generic"
When you login via tty, ssh, or su --login - your $SHELL is launched for you. This is called a "login" shell, and it will automatically source the following files:
1) /etc/profilethen
2) ~/.profile or ~/.bash_profileWhen you launch /bin/bash by some other means (xterm, konsole, su, or even typing /bin/bash) it is considered non-login and it WILL source .bashrc
(but generally not both, one will take "precedence")
It is VERY common for ~/.profile (or ~/.bash_profile) to source ~/.bashrc by either:
. ~/.bashrcor
source ~/.bashrcYou can use source either way - in both interactive and non-interactive shells.
/etc/profile may source lots of other files. Sometimes /etc/bashrc (or /etc/bash.bashrc) and sometimes even ~/.bashrc - so watch out!
Your system may not have all these files - or they may have different names. Try:
ls -al /etc/ | grep bashrcto get some different ideas.
ls -al /etc/ | grep profile
ls -al ~ | grep bashrc
ls -al ~ | grep profile
the command "su -" is short hand for "su --login root" or "switch user to root and launch a login shell"
it is NOT "switch to super user and load environment variables" (even if that may be the case on some systems)
1 comment:
Nice blog, thanks for posting
Post a Comment