Reconfigure locale

Changing the language of a Linux installation can be done by the following commands.

The settings itself are stored in the file /etc/default/locale:

LANG=de_DE.UTF-8

It can contain more settings if different languages should be used for different aspects of the systems.

The current active locale can be displayed by the following command:

root@machine:~# locale
LANG=de_DE.UTF-8
LANGUAGE=
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

All available locales can be displayed by the following command:

root@machine:~# locale -a
C
C.UTF-8
de_DE.utf8
en_US.utf8
POSIX

You can also get some extra information adding the -v (verbose) parameter:

root@machine:~# locale -a -v
locale: de_DE.utf8      archive: /usr/lib/locale/locale-archive
-------------------------------------------------------------------------------
    title | German locale for Germany
   source | Free Software Foundation, Inc.
  address | http://www.gnu.org/software/libc/
    email | bug-glibc-locales@gnu.org
 language | German
territory | Germany
 revision | 1.0
     date | 2000-06-24
  codeset | UTF-8

locale: en_US.utf8      archive: /usr/lib/locale/locale-archive
-------------------------------------------------------------------------------
    title | English locale for the USA
   source | Free Software Foundation, Inc.
  address | http://www.gnu.org/software/libc/
    email | bug-glibc-locales@gnu.org
 language | American English
territory | United States
 revision | 1.0
     date | 2000-06-24
  codeset | UTF-8

locale: C.UTF-8         directory: /usr/lib/locale/C.UTF-8
-------------------------------------------------------------------------------
    title | C locale
    email | aurel32@debian.org
 language | C
 revision | 1.6
     date | 2016-08-08
  codeset | UTF-8

The locale can be changed by the following command (changes the locale to German):

root@machine:~# update-locale LANG=de_DE.UTF-8

If you get an error message, maybe the locale you defined doesn't exist yet. So you have to create it by the following command:

root@machine:~# locale-gen --purge de_DE.UTF-8

The --purge parameter will remove existing locales before processing.

Another way to create locales is the following command - which will show a dialog for doing so:

root@machine:~# dpkg-reconfigure locales

Locales are cached in the file /usr/lib/locale/locale-archive. This cache can be modified by the following commands.

All locales in the archive can be listed by:

root@machine:~# localedef --list
de_DE.utf8
en_US.utf8

A locale can be deleted from the archive by (deletes the German locale, but must be one of the locales printed by the --list parameter):

root@machine:~# localedef --delete-from-archive de_DE.utf8

Sources