24

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

2
  • 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. Jan 9, 2014 at 9:01
  • centos version 5.7
    – ohho
    Jan 9, 2014 at 9:07

2 Answers 2

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).

5
  • What does the dot does? I there any other uses of it?
    – lepe
    Aug 31, 2017 at 2: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. Aug 31, 2017 at 6:53
  • Synonymous with source /etc/default/locale. Jun 26, 2021 at 7: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. Jun 30, 2022 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, 2022 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.

2
  • su youruserid - - really?! Why not simply exit the shell and restart it?! Jan 9, 2014 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 9, 2014 at 10:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .