Bash startup files

Categories:

Bash Startup Files Parsing Order

File-li-l-i
/etc/profile11
~/.bash_profile2.12.1
~/.bash_login2.22.2
~/.profile2.32.3
~/.bashrc1
$BASH_ENV1
~/.bash_logout33

Options and modes

  • -l — login shell
  • -i — interactive shell

Notes

  • Login Bash sources the first existing and readable file from the following list:
    • ~/.bash_profile
    • ~/.bash_login
    • ~/.profile
  • ~/.bashrc is sourced by Bash as interactive shell only.
  • $BASH_ENV:
    • environment variable with the filename of init script;
    • sourced only before executing Bash script as non-interactive shell;
    • applied expansions (in order):
      • parameter expansion;
      • arithmetic expansion;
      • command substitution.

See Also