What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc ...?
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.
I think this question is too broad on so many levels, e.g. you are asking questions about at least four different programs in one question. I'll only look at the difference between the configuration files in /etc
and $HOME
.
Unix is a multi-user operating system, this means many different persons can use a system, either by using ssh
, telnet
, or Xorg
. To provide a standardized configuration for your users you can provide a system wide configuration in /etc/
, this is typically also used by your Distribution to provide a global configuration for e.g. bash
or screen
.
On the other hand, some users want to customize the settings for their programs on their own like keybindings, colors or look. This is done via the configuration file in their $HOME
. So in short /etc/
provides system wide configuration while the config files in $HOME allow users to change/override the system wide configuration.
Part of the answer comes from this post:
.bashrc
is a shell script that Bash runs whenever it is started interactively.
Contrast .bash_profile
and .profile
which are only run at the start of a new login shell. (bash -l)
You choose whether a command goes in .bashrc
vs .bash_profile
depending on on whether you want it to run once or for every interactive shell start.