What's the difference between the following files in CentOS 7?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
For any program that simply needs to read the environment variable settings,
/etc/environment are basically the same; in a very simplified embedded system, you could omit
/etc/locale.conf and place any required locale variables to
The difference is mainly in how to deal with updating the files.
/etc/locale.conf, the set of variables expected to be defined in the file is finite and their syntax is well-defined. This allows easier modification by programs. For example, a "language/locale settings" GUI application can easily read the existing settings, present them to the user, and then re-write the entire file if the user makes new choices.
Recovery from syntax errors is simple too: if the settings application detects a syntax error in the file, it can just present the settings it managed to read, let the user either accept the current configuration or make changes, and then re-write the file based on some template built into the application, and the error is transparently fixed.
/etc/environment, the set of environment variables that can be defined there is unlimited, so any programmatic manipulations of the file must be done much more carefully.
/etc/locale.conf define system-wide defaults, while
~/.bashrc is specific to the user: using
~/.bashrc, the user can override the system defaults for their own session(s) only, if desired.