3

I'm running KDE neon 5.20 and found two files /etc/locale.conf and /etc/default/locale with similar content. What's the difference between these two files and which one should I edit to change the system locale?

muru
  • 69,900
  • 13
  • 192
  • 292
popov895
  • 31
  • 5

3 Answers3

3

Many application softwares need the LANG environment variable to work. So most distros have a startup script to set LANG after login.

So where does the startup script read the LANG config from? It's different among distros, e.g.

  • Debian default console login startup script reads /etc/default/locale
  • Slackware default console login startup script dot-sources /etc/profile.d/lang.sh
  • KDE Plasma reads ~/.config/plasma-localerc
  • Some other distros read /etc/locale.conf

Systemd doesn't know what distro it is installed on. So when you're gonna modify the config with localectl, localectl detects whether /etc/locale.conf exists. If it exists, then localectl modifies it, or it modifies /etc/default/locale as a fallback.

As far as Ubuntu(Non-GUI) is concerned, in case /etc/locale.conf exists, you will find that no matter how you run localectl, the LANG variable is retained after reboot. That's because Ubuntu uses /etc/default/locale, and localectl modified a file which will never be read by Ubuntu.

Zim
  • 179
  • 1
  • 5
0

Different distributions or versions of Linux employ one or the other. As a case in point, the documentation for Debian 10 refers mainly to /etc/default/locale (e.g. man update-locale). Its systemd-related parts refer also to /etc/locale.conf (e.g. man locale.conf).

A brief test shows that localectl (also part of Debian 10's systemd) reports the contents of /etc/default/locale as system locale, unless /etc/locale.conf exists as well: in this case it apparently takes precedence.

I am using /etc/default/locale exclusively (again, on a current version of Debian). My rational is as follows: this one can be appropriate for Debian, either one is appropriate for system, so in sum it's a clear choice.

rookie099
  • 127
  • 6
  • I still don't understand why there are two files. If I set `LC_TIME=en_US.UTF-8` in **/etc/default/locale** and `LC_TIME=en_GB.UTF-8` in **/etc/locale.conf**, what will the LC_TIME be as a result (I don't have Ubuntu installed at the moment to check this)? – popov895 Apr 14 '21 at 18:15
  • @popov895 Well I guess there are two different lineages. An older one that employs `/etc/locale.conf` and a newer one that employs `/etc/default/locale`. – rookie099 Apr 15 '21 at 07:43
0

After some experiments, I've determined that KDE neon respects the locale settings in /etc/default/locale, but ignores the locale settings in /etc/locale.conf. I still don't understand why Ubuntu uses a different location for the locale file, but I came to the conclusion that on Ubuntu based distributions it's necessary to use /etc/default/locale to set the locale. Also, I just replaced /etc/default/locale with a symlink to the /etc/locale.conf, and everything works fine, but now I have only one file with the locale settings.

muru
  • 69,900
  • 13
  • 192
  • 292
popov895
  • 31
  • 5