In this article, we will explain how to modify system locales in Linux.
System locales define the language, country, character encoding. It will beneficial for application as well as shell session and system libraries use system locales in Linux. Locales play a crucial role to identify the time/date format, the first day of the week, numbers, currency, and many other values formatted in accordance with the language or region/country you set on a Linux system.
So, let’s get started and check currently installed system locales as well as how we can modify the system’s locale in Linux
How to View System Locale in Linux
To view information about the currently installed locale, use the locale or localectl utility.
# localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: n/a
X11 Layout: us
X11 Model: pc105
To check more information about environmental variable, for example LC_TIME:
# locale -k LC_TIME
d_t_fmt=”%a %d %b %Y %r %Z”
date_fmt=”%a %b %e %H:%M:%S %Z %Y”
To display a list of all available locales use the following command.
# locale -a
How to Set System Locale in Linux
To modify system locales, use the update-locale or localectl command. The LANG variable allows you to set the locale for the entire system.
The following command sets LANG to en_IN.UTF-8 and removes definitions for LANGUAGE.
# update-locale LANG=LANG=en_IN.UTF-8 LANGUAGE
# localectl set-locale LANG=en_IN.UTF-8
To configure a specific locale parameter, edit the appropriate variable. For instance.
# sudo update-locale LC_TIME=en_IN.UTF-8
# sudo localectl set-locale LC_TIME=en_IN.UTF-8
You can find global locale settings in the following files:
/etc/default/locale – on Ubuntu/Debian
/etc/locale.conf – on CentOS/RHEL
You can edited those values manually too. For that open ~/.bash_profile file and add following lines:
We have seen how to modify system locales in Linux.
[Need assistance to fix this error or install tools? We’ll help you.]