Bash startup files
When Bash invoked as an interactive login shell, the following happens:
- Bash looks for
/etc/profileand runs all comands listed in there. - Bash search for
~/.bash_profile,~/.bash_login,~/.profilefiles 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_profilefor describe commands that run only once, such as customing the$PATHdirectory. - use the
.bashrcif 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_profilebut for all users -
/etc/bashrc- like~/.bashrcbut 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.