What’s the difference between ~/.bashrc, ~/.bash_login, ~/.bash_logout, ~/.bash_profile, ~/.profile, /etc/profile, /etc/bash.bashrc, /etc/ssh/ssh_config and sshd_config, when are they loaded and what are their purposes?
What’s the difference between ~/.bashrc, ~/.bash_login, ~/.bash_logout, ~/.bash_profile, ~/.profile, /etc/profile, /etc/bash.bashrc, /etc/ssh/ssh_config and sshd_config,
Share
The man page for bash says there are the following initialization files for bash shells:
Apparently there seem to be different configuration files for the different shells (bash, zsh, csh, and others). There seem to be as many shells as different linux and unix versions: csh, ksh, bash, zsh, … Bash has a
.bashrc, Zsh has a.zshrc, etc. One can also distinguish between login shells and non-login shells and between system-wide defaults and user-specific defaults.It makes sense to distinguish between login and non-login shells, because some commands should be processed only at login, while other commands should run everytime you open a new terminal window. That is the difference between .bash_profile and .bashrc. For bash the
.bashrcis reloaded every time you start a new copy of bash, i.e. when you start a new bash but do not login. The.bash_profileor.profileis loaded only when you login. The abbtreviation rc in bashrc stands for “run commands” or “run control” and is a convention adopted from older Unix systems.system-wide defaults for..
/etc/profile..login shells, for interactive shells with login/etc/bashrc..non-login Bash shellsuser-specific defaults in home directory ~ for..
~/.profile..login shells, called after login~/.bashrc..non-login shells, if already logged in~/.bash_profile..login shells, called after login (lower priority)user-specific defaults in home directory for login and logout
~/.bash_login..login shells (called upon login)~/.bash_logout..login shells (called upon logout)The following links were helpful: .bashrc vs .bashprofile and .bash_profile vs .bashrc, the bash manual page (man bash), and Zsh/Bash startup files loading order (.bashrc, .zshrc etc.).