Перейти к содержанию

Bash startup files


When Bash invoked as an interactive login shell, the following happens:

  1. Bash looks for /etc/profile and runs all comands listed in there.
  2. Bash search for ~/.bash_profile, ~/.bash_login, ~/.profile files and executes commands from first readble file found.

When Bash is invoked as an interactive nonlogin shell, it reads and executes command from ~/.bashrc file (if that file exist and readable) So:

  • use the .bash_profile for describe commands that run only once, such as customing the $PATH directory.
  • use the .bashrc if you need to use command from it often.

Also Bash operate with some another files:

  • ~/.profile - in some Linux based systems. Use not for only Bash rather for another shell interpretors

  • etc/profile - like ~/.bash_profile but for all users

  • /etc/bashrc - like ~/.bashrc but for all users

Usually ~/.bash_profile refer to ~/.bashrc (run all comands from it).

Warning

Change which was write down on the ~/.bash_profile, will be active after relog.