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.
# locale
LANG=en_US.UTF-8
LANGUAGE=en_US
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=# localectl status
System Locale: LANG=en_US.UTF-8
LANGUAGE=en_US
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
abday=”Sun;Mon;Tue;Wed;Thu;Fri;Sat”
day=”Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday”
abmon=”Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec”
mon=”January;February;March;April;May;June;July;August;September;October;November;December”
am_pm=”AM;PM”
d_t_fmt=”%a %d %b %Y %r %Z”
d_fmt=”%m/%d/%Y”
t_fmt=”%r”
t_fmt_ampm=”%I:%M:%S %p”
era=
era_year=””
era_d_fmt=””
alt_digits=
era_d_t_fmt=””
era_t_fmt=””
time-era-num-entries=0
time-era-entries=”S”
week-ndays=7
week-1stday=19971130
week-1stweek=1
first_weekday=1
first_workday=2
cal_direction=1
timezone=””
date_fmt=”%a %b %e %H:%M:%S %Z %Y”
time-codeset=”UTF-8″
alt_mon=”January;February;March;April;May;June;July;August;September;October;November;December”
ab_alt_mon=”Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec”
To display a list of all available locales use the following command.
# locale -a
C
C.UTF-8
en_US.utf8
POSIX
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
OR
# 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
OR
# 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:
LANG=”en_IN.utf8″
export LANG
We have seen how to modify system locales in Linux.
[Need assistance to fix this error or install tools? We’ll help you.]