Thursday, August 11, 2016

bash Configuration Files

If you’re using a non-login shell, things are pretty straightforward. The bash shell simply runs /etc/bashrc for system-wide functions and aliases, and then it runs ~/.bashrc from the user’s home directory for user-specific customizations.


If you’re using a login shell, bash first runs /etc/profile and applies the configurations speci-fied in that file. After that, however, things get a little more complex. As you may have noticed in Table 2-1, several of the files listed sound like they do exactly the same thing. You’re right, they do. The issue here is that no distribution uses all of these files. For example, a Fedora system uses ~/.bashrc, ~/.bash_profile, and ~/.bash_logout. Alternatively, openSUSE and Ubuntu systems use ~/.bashrc and ~/.profile.


When a login shell is run, the bash shell program searches for configuration files in the following order:


1.~/.bash_profile
2.~/.bash_login
3.~/.profile



It uses the first file it finds and ignores all of the rest.

No comments:

Post a Comment