≡ Menu

How to Set Locales (i18n) On a Linux or Unix

What is a “locale” on a Linux operating system? How do I set or get locals (i18n) values on a Linux operating system?

Locales defines language and country specific setting for your programs and shell session. You can use locales to see date, time, number, currency and other values formatted as per your country or language on a Linux or Unix-like system. To set system’s locale you need use shell variable. For example, LANG variable can be used to set en_US (English US) language.

How do I show current locale settings on a Linux or Unix?

The syntax is:

locale name
locale [options] name


Simply type the following command:
$ locale

Fig.01 Show current locale on a Linux or Unix

Fig.01 Show current locale on a Linux or Unix

Display all available locales on your Linux or Unix-like system

Pass the -a option to locale command:
$ locale -a
Sample outputs:


You also run the following command on a Debian or Ubuntu based system to see the list of all supported locales:
$ less /usr/share/i18n/SUPPORTED
Sample outputs:

aa_DJ.UTF-8 UTF-8
aa_DJ ISO-8859-1
aa_ER UTF-8
aa_ER@saaho UTF-8
aa_ET UTF-8
af_ZA.UTF-8 UTF-8
af_ZA ISO-8859-1
ak_GH UTF-8
am_ET UTF-8
an_ES.UTF-8 UTF-8
an_ES ISO-8859-15
anp_IN UTF-8
ar_AE.UTF-8 UTF-8
ar_AE ISO-8859-6
ar_BH.UTF-8 UTF-8
ar_BH ISO-8859-6
ar_DZ.UTF-8 UTF-8
el_CY ISO-8859-7
en_AG UTF-8
en_AU.UTF-8 UTF-8
en_AU ISO-8859-1
en_BW.UTF-8 UTF-8
en_BW ISO-8859-1
en_CA.UTF-8 UTF-8
en_CA ISO-8859-1
en_DK.UTF-8 UTF-8
en_DK.ISO-8859-15 ISO-8859-15
en_DK ISO-8859-1
en_GB.UTF-8 UTF-8
en_GB ISO-8859-1
en_GB.ISO-8859-15 ISO-8859-15
en_HK.UTF-8 UTF-8
en_HK ISO-8859-1
en_IE.UTF-8 UTF-8
en_IE ISO-8859-1
en_IE@euro ISO-8859-15
en_IN UTF-8
zh_CN.GB18030 GB18030
zh_CN GB2312
zh_HK.UTF-8 UTF-8
zh_SG.UTF-8 UTF-8
zh_SG GB2312
zh_TW.UTF-8 UTF-8
zh_TW BIG5
zu_ZA.UTF-8 UTF-8
zu_ZA ISO-8859-1

View/set global locale for all users on a “CentOS/RHEL/Scientific Linux v5.x/6.x” and older

Edit or view /etc/sysconfig/i18n to set global locale for all users:
$ sudo cat /etc/sysconfig/i18n
$ sudo vi /etc/sysconfig/i18n
Sample outputs:


You can also edit /etc/profile and set global locale for all users:

export LANG

View/set global locale for all users on a “Fedora Linux v22” and “CentOS/RHEL/Scientific Linux 7.x” and above

Type the following command to see the current locale for all users:
$ cat /etc/locale.conf
Sample outputs:


You can use the following systemd command too:
$ localectl status
Sample outputs:

   System Locale: LANG=en_IN.UTF-8
       VC Keymap: in-eng
      X11 Layout: in
     X11 Variant: eng

To see all locales available, run:
$ localectl list-locales
To set the default global system locale for all users, type the following command as root:
$ sudo localectl set-locale LANG=localeValueHere
$ sudo localectl set-locale LANG=en_IN.UTF-8

View/set global locale for all users on a Debian or Ubuntu Linux

To see which locales are supported on Debian/Ubuntu, enter:
$ locale -a|more
To set the locales for all users, enter:
$ sudo locale-gen en_IN
$ sudo locale-gen en_IN.UTF-8

Finally run:
$ sudo update-locale
Another option is to run dpkg-reconfigure locales command and select the locale(s) you want to generate. At the end, you’ll be asked which one should be the default. If you have users who access the system through ssh, it is recommended that you choose None as your default locale:
$ sudo dpkg-reconfigure locales

How can I set global locale for one user?

Simply edit your bash shell profile file $HOME/.bash_profile:
$ vi ~/.bash_profile
Append/add/edit as follows:

export LANG

OR create a new .i18n file to user’s $HOME directory:
$ vi $HOME/.i18n
Append/add/edit the following as per your locale setting:


Save and close the file. Please note that ~/.bash_profile procedure should work on Linux, OS X, *BSD and many other Unix-like systems.

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 0 comments… add one }

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: