What's the difference between the following files in CentOS 7?

  • /etc/locale.conf
  • /etc/environment
  • ~/.bashrc
  • any bashrc file is for bash shell. The other two files are shell-independent. An app started at boot could check environment and locale.conf to see what environment variables are set, which locale is used by the system, in which locale to write logs, etc – Sergiy Kolodyazhnyy Jun 3 '19 at 2:06
  • @SergiyKolodyazhnyy but why two file? why not use environment only? why not just use locale.conf only? what's the exactly difference between this two file? – Willis Jun 3 '19 at 2:13
  • 2
    /etc/locale.conf is used to set language and coutry settings, such as the currency symbol ..... /etc/environment sets systemwide settings, such as the PATH variable, default editor, etc – jsotola Jun 3 '19 at 4:20

For any program that simply needs to read the environment variable settings, /etc/locale.conf and /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 /etc/environment instead.

The difference is mainly in how to deal with updating the files.

For /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.

For /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.

Also, /etc/environment and /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.

  • Thank you, I found that /etc/locale.conf only appear in CentOS7, and this file can be set by one of systemd component - localectl while /etc/environment should be edit by yourself. In CentOS6 or earlier version, there is a /etc/sysconfig/i18n, but this file was removed in CentOS7, so is that /etc/locale.conf is the replacement of /etc/sysconfig/i18n ? – Willis Jun 3 '19 at 6:56
  • 1
    Yes. /etc/sysconfig/i18n (and in fact the entire /etc/sysconfig directory) was a classic RedHat-style solution, while /etc/locale.conf might become the new standard across most Linux distributions. Likewise, RedHat/CentOS/Fedora and related distributions used to include tools (both command line and GUI) to manipulate /etc/sysconfig/i18n, while /etc/environment was left to the system administrator to edit manually. – telcoM Jun 3 '19 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.