24

After making changes to /etc/default/locale, is it possible to reload/active the new settings without a reboot?

ohho
  • 343
  • 1
    Which distribution? Console or GUI? But often reloading /etc/profile or logging in again helps. You usually do not need to reboot a linux system for anything but a kernel update. – ThiefMaster Jan 09 '14 at 09:01
  • centos version 5.7 – ohho Jan 09 '14 at 09:07

2 Answers2

17

Locale settings are set as environment variables by the login process (which reads /etc/default/locale) and inherited by child processes. If you log in to a new session, the new settings take effect in the new session.

You can make the settings take effect immediately in a shell by issuing the command

. /etc/default/locale

(note the leading dot). If you've added a category that wasn't set before, you'll need to export it. If you've removed a category, you'll need to unset it.

Changing the settings in a shell affects all the applications subsequently started by that shell (as long as they're using the system locale settings and not their own configuration method).

  • What does the dot does? I there any other uses of it? – lepe Aug 31 '17 at 02:25
  • 1
    @lepe It's a shell builtin to read and interpret the given file. The file is interpreted in the current shell, as opposed to just writing /etc/default/locale which would execute that file as a separate program, which is pointless when all the file does is set variables. – Gilles 'SO- stop being evil' Aug 31 '17 at 06:53
  • Synonymous with source /etc/default/locale. – Константин Ван Jun 26 '21 at 07:52
  • Sourcing the locale file will not reset existing environment variables unless they are explicitly given in /etc/default/locale. Furthermore, variables given will not be exported, so this does not work correctly unless the current and new configuration is very similar. – Remember Monica Jun 30 '22 at 12:46
  • This did not work for me on Debian, for example the PostgreSQL command pg_lsclusters was still complaining about unset locale variables. So I had to reboot. By reading the answer again, I noticed the other solution with export. It could be useful to mention above the first solution with the dot instead of below that it will not work in some cases, so people will not think it will work when trying it. – baptx Nov 10 '22 at 14:35
2

If your are using a shell, then just start a new login eg. su youruserid -

test it then exit back to your original login shell

If you are using a gui, logout and login again.

X Tian
  • 10,463
  • su youruserid - - really?! Why not simply exit the shell and restart it?! – ThiefMaster Jan 09 '14 at 10:10
  • Because I would loose my "context", say I was developing a program, then starting a sub shell allows me to test then exit, I am still in the development directory, ready to try again. Of course logout and login will work, but starting a sub shell is quicker in my opinion. – X Tian Jan 09 '14 at 10:17