Answers to the questions on SO and askubuntu, along with poking through (and reading headers of) $HOME
and /etc/
, indicate a number of files that can be used to set environment variables, including:
~/.profile
~/.bashrc
~/.bash_profile
~/.gnomerc
~/.Rprofile
/etc/bash_bashrc
/etc/profile
/etc/screenrc
I gather that files in /etc/
work for all users whereas files in $HOME
are user-specific. I also gather that .profile
is loaded at login whereas .bashrc
loaded when /bin/bash
is executed. I also understand that different programs have different settings files (e.g. .Rprofile
for R). But I would appreciate some clarification:
- Are
*rc
and*profile
files fundamentally different? - What is the scope of such files (e.g. which files are are commonly used with Linux)
- Is there a hierarchy (e.g.
.bashrc
overwrites variables set in.settings
) - What is a good reference for this class of files? For the options in these files?
Best Answer
The organization of configuration files is much less uniform than your questions seem to imply. There is no "class", there is no "hierarchy", and there is no global "configuration czar" nor committee that decrees a common syntax or other nice clean generalizations like the ones you are seeking. There is only a multitude of separate applications like
R
,bash
,screen
and the GNOME desktop environment, all of whom have their own ways of doing things, so you should look at the documentation for each individual program to answer any specific questions about a particular file. If it seems ad-hoc, that's because it is: most of Unix / Linux software out there was developed for different purposes by different people who all went about configuration slightly differently.To answer your other questions pointwise:
*rc
and*profile
do not mean very much, so this question can't really be answered. "rc" is merely a commonly used abbreviation or suffix for configuration files. Its etymology goes back to ancient times (in computer years), and probably means run commands (from runcom). Just because applications use the same word does not mean they agree on conventions. "profile" is a much less common suffix.Define "scope". Most applications do not share configuration files with other non-related applications. The one possible exception is
/etc/profile
and.profile
, which may be used by multiple different shells (including at leastsh
andbash
). There is something called an environment associated with every running process which can contain variables that may affect the behavior of said process. Generally, environment variables are set by the appropriate shell configuration files, or perhaps the configuration files of whatever graphical desktop environment you are using. There are also configuration files for "libraries", like.inputrc
for readline and.gtkrc*
for GTK, which will affect every application that uses the library.No, there is no global hierarchy for configuration files. Again, refer to the documentation for the specific program in question, for example, the
bash
manual forbash
. A general convention you can usually rely on is that user settings in$HOME
override system-wide configuration in/etc
. This is typically accomplished by reading the user file after the system one, so that later settings overwrite earlier ones. However, this is not a guarantee, and for definitive answers you should refer to the documentation for the specific program you are using.There is no "class", at least none general enough to encompass all the files you've listed in your question, so the question of a reference for such a "class" is moot. Again, refer to the documentation of the specific program you are using.