How to Change or Set System Locales in Linux

LinuxOperating SystemSoftware & Coding

We often need to customise the operating system to become useful to our own preferences like the language we want to use the time zone we are in the type of currency which would become the default currency in the OS etc. In this article we will see how to customise these options which is known as locale.

Current locale

We can check the current locally by using the locale command as shown below. We get list of variables which can be reset to a different value as per our choice later

$ locale

Running the above code gives us the following result −

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=

All Available locale

To get all the available locale we use the below command. It just displays the locale values.

$ locale -a

Running the above code gives us the following result −

C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
. . .
en_IN
en_IN.utf8
en_NG
. . .
en_ZM.utf8
en_ZW.utf8
POSIX

Details of a Specific Variable

The specific variable details can be obtained by using the variable name along with the –c and –k switch.

$ locale -c -k LC_TIME

Running the above code gives us the following result −

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"
. . .
. . .
timezone=""
date_fmt="%a %b %e %H:%M:%S %Z %Y"
time-codeset="UTF-8"

Change locale

To change the value of a locale which is already set, we can edit the .bashrc profile of the use who needs the new locale.

$ sudo nano ~/.bashrc
#And add the following lines at end
LANG="en_IN.utf8"
export LANG

$ locale

Running the above code gives us the following result −

$ locale
LANG=en_IN.utf8
LANGUAGE=en_US
LC_CTYPE="en_IN.utf8"
LC_NUMERIC="en_IN.utf8"
. . .
raja
Published on 14-Feb-2020 14:55:24
Advertisements