How to Change System Language (Locale) in Ubuntu and Debian?

PowerADM.com / Linux / Debian / How to Change System Language (Locale) in Ubuntu and Debian?

Locale settings determine the operating system language and regional settings used in the terminal and in the graphical interface (date and time format, currency symbols, available character sets, etc.). This article will look at how to check or set locale settings on Linux distros (Ubuntu, Debian, Mint, etc.).

You can list the current locale settings in Ubuntu and Debian using the command:

$ locale

get locale in ubuntu linux

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

List of available locales on the host:

$ locale –a

list available system locales

To display detailed information about the locales installed on the current Linux host:

$ locale -a -v

The C.UTF-8 system locale is always present in this list. Let’s try to add the German locale de_DE.UTF-8.

The list of locales available for installation is listed in the file:

$ cat /etc/locale.gen

To install the locale you need, run the command:

$ sudo locale-gen de_DE.UTF-8

locale-gen - generate new locale fles

You can also enable locales you need by uncommenting the lines in the file /etc/locale.gen:

/etc/locale.gen

To set the default locale, use the command:

$ sudo update-locale LANG=de_DE.UTF-8

or:

$ sudo localectl set-locale LANG=de_DE.UTF-8

This command will write the following line to the /etc/default/locale:

LANG=de_DE.UTF-8

Reboot the Linux host to apply the new locale settings.

You can set a separate locale for different parts of Linux, for example:

$ sudo update-locale LC_NUMERIC=en_US.UTF-8 LC_TIME=en_US.UTF-8 LC_MONETARY=en_US.UTF-8

If you specify a locale that has not yet been generated, the locale command will return errors:

$ locale

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=fr_FR.utf8

In some cases, you must first set the required locale:

$sudo apt-get install language-pack-fr

If the locale is not set on Linux and the locale -a command returns only three entries:

C
C.UTF-8
POSIX

  1. You need to generate new locale settings:
    sudo locale-gen de_DE.UTF-8
  2. Apply new locale:
    sudo update-locale LANG=de_DE.UTF-8
  3. Reboot the host or open a new terminal window

For easier locale management on Debian and Ubuntu, you can use the dpkg-reconfigure tool.

With the following command you can generate, set, or remove locales on Linux:

$ sudo dpkg-reconfigure locales

The utility provides a simple pseudo-graphical interface. Select the locales to install.

dpkg-reconfigure locales

Then set the default locale (default locale for the system environment).

dpkg-reconfigure set default locale for the system environment

To change the encoding in the console (terminal), run the command:

$ sudo dpkg-reconfigure console-setup

Select UTF-8 encoding for the console, then choose which character set support to add.

dpkg-reconfigure console-setup

These settings are stored in:

$ cat /etc/default/console-setup

Then configure the keyboard:

$ sudo dpkg-reconfigure keyboard-configuration

The default recommended keyboard model is Generic 105-key PC. Then add the keyboard mappings (keymaps) for the desired country.

Keyboard settings are specified in the file:

$ cat /etc/default/keyboard

It remains to set the time zone:

$ sudo dpkg-reconfigure tzdata

You can remove locales you don’t use. The list of installed locales is in /usr/lib/locale/locale-archive.

List the locales in the archive:

$ localedef --list-archive

delete locales in linux with localedef

Delete the locale:

$ sudo localedef --delete-from-archive en_IN.utf8
Leave a Reply

Your email address will not be published. Required fields are marked *