Set system locale on Linux

How to change language using localectl set-locale

Locales consist of a set of environment variables to define language, country, and character encoding for applications and shell sessions on a Linux system. These environment variables are used by system libraries and country-specific applications on the system.

The locale affects the time and date format, first day of the week, numbers, currency, and many other values formatted according to the language or region (country) set on a Linux system.

The locale and localectl utility provides information about the currently installed locale and changes it when needed.

Output a list of all available locales.

Change system locale

If you want to change the locale, the update-locale and localectl command is used. The LANG variable can be used to set the locale for the entire system.

The following command sets LANG to de_DE.UTF-8

To set a locale for a single user, you can simply open the file .bash_profile and add the following lines.

For Debian 10 (Buster), the dpkg-reconfigure service program is a good way to set the system locale.

The locale settings are located in the following files.

  • /etc/default/locale – Ubuntu/Debian
  • /etc/locale.conf – CentOS/RHEL

These files can also be edited manually using a preferred command line editor, such as Vim or Nano, to configure the system locale.

Further help can be found in the man pages.

Leave a Reply

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