Last Modified: Wed, 05 Feb 2014 19:15:11 +0000 ; Created: Wed, 05 Feb 2014 19:13:22 +0000
|Some notes on how bash reads startup files. Some distros compile with the SYS_BASHRC flag which can add some startup files.
In most cases /etc/bashrc (or similar /etc) files are not read by bash itself by are sourced by other startup files instead. See /etc/profile, ~/.bash* files, ~/.profile, and /etc/skel/.bash* (or .profile) files.
login shell (interactive or non-interactive) /etc/profile First one that is readable ~/.bash_profile ~/.bash_login ~/.profile Can use --noprofile option to disable all of these above options Upon exit reads ~/.bash_logout (and some distros /etc/bash.bash_logout) non-login shell + interactive /etc/bash.bashrc (Ubuntu/Debian SYS_BASHRC special) ~/.bashrc Can use --norc to disable Can use --rcfile to force one specific file instead "sh" invocation /etc/profile ~/.profile
You also see on some distros /etc/bashrc (versus /etc/bash.bashrc). This is typically (see SYS_BASHRC for exception) not read by bash itself but instead sourced by ~/.bashrc (which is typically sourced by ~/.profile or ~/.bash_profile).
Other invocation methods have environment variables that specify a startup file to read. POSIX mode (--posix) turns off startup files except for env.
Consult the bash man page or Bash Reference Manual for more info.
To tell if your distro uses the SYS_BASHRC compile option try "man bash" on your running distro and look in the INVOCATION section.