A locale is a set of environmental variables that defines the language, country, and character encoding settings (or any other special variant preferences) for your applications and shell session on a Linux system. These environmental variables are used by system libraries and locale-aware applications on the system.
Locale affects things such as 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.
In this article, we will show how to view your currently installed system locale and how to set system’s locale in Linux.
How to View System Locale in Linux
To view information about the current 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
You can view more information about an environmental variable, for example LC_TIME, which stores the time and date format.
$ 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
If you want to change or set system local, use the update-locale program. 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.
$ sudo update-locale LANG=LANG=en_IN.UTF-8 LANGUAGE OR $ sudo 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
These files can also be edited manually using any of your favorite command line editors such as Vim or Nano, to configure your system locale.
To set a global locale for single user, you can simply open ~/.bash_profile file and add the following lines.
LANG="en_IN.utf8" export LANG
For more information, see the locale, update-locale and localectl man pages.
$ man locale $ man update-locale $ man localectl
That’s all! In this short article, we have explained how to view and set system local in Linux. If you have any questions, use the feedback form below to reach us.
Hi,
If I do:
Does this also remove the thousands of locale directories from all the programs or does it just deactivate their use of them?
Whoever thought that the language of week- and month-names should be tied to the user’s locale and not the user’s display language was a really clever monkey. Take, for example, my system configured for English but a Hungarian locale: everything on my system displays in English EXCEPT for days and months which are in Hungarian!!!
Seriously?! It must be the most illogical design that I have come across and it seems to be quite common on Linux systems. Nutters. Oh, and user-customization of locales is something completely overlooked on most Linux desktops. Argh!
There’s a double
LANG=
in the section ”How to Set System Locale in Linux“Where it says:
should say:
and even better:
… to update the locale of the current user, rather than root’s.
Never mind for the last line, update-locale needs to be run as root.
@Pedro
Many thanks for sharing this. We will look into this further.
I have tried following the instructions here several times, but I still have the calendar showing Monday as the first day of the week, despite changing it to Sunday, i.e. day 1, using en_GB. The en_GB defaults to day 2, so I changed it and updated, etc. but it stays on a wrong day for the calendar.
Resume:
1. This is on Ubuntu
2. This is don’t work
3. Pointed utilities unknown and absent and can’t be installed. Because of those utilities absent in any repository in you OS.
So information is fully useless.
@Anatoly
Which OS are you using?
Hi! I don’t have command
update-locale
on my MAC. What should I do?@Poul
I have never used a Mac OS so I can’t tell how you can install it. But try to use this guide to set system locale:
To view or set the region on Mac OS X 10.10:
Select System Preferences >Language & Region.
Select a region and country from Region.
Hi! How can I change locale’s vars? What command should I do? If I write in Terminal, for example, “
LC_COLLATE="ru_RU.UTF-8
”var LC_COLLATE=
does not change.