Bootstrap FreeKB - Linux Commands - Linux LANG variable with examples
Linux Commands - Linux LANG variable with examples

Updated:   |  Linux Commands articles

The LANG variable defines the language of the system. In the example, the LANG variable is set to en_US.utf8 (English, USA, Unicode).

[root@server1 ~]# echo $LANG
en_US.utf8

 

Typing a bogus command will produce an error in the langugae defined in the LANG variable (English in this example).

[root@server1 ~]# asdfasdfsd
-bash: asdfasdfsd: command not found

 


Change language system wide

The locale -a or locale --all-locales command can be used to displays all of the possible locales that can be used.

[root@server1 ~]# locale -a
. . .
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
es_US
es_US.iso88591
es_US.utf8
unm_US
unm_US.utf8
yi_US
yi_US.cp1255
yi_US.utf8
. . .

 

If the locale you want to use is not listed, you can use the locale-gen command to generate the locale. The locale you want to generate must be in the /etc/locale.gen file.

[root@server1 ~]# locale-gen fr_FR.iso885915

 

The update-locale command can be used to update the LANG variable for the entire system. For example, to update the LANG to de_DE.utf8 (German, Germany, Unicode).

[root@server1 ~]# update-locale LANG=de_DE.utf8

 

The locale command without any options displays the contents of the /usr/bin/locale file. In this example, the LANG has been set to de_DE.utf8 (German, Germany, Unicode).

[root@server1 ~]# locale
LANG=de_DE.utf8
. . .

 

Typing a bogus command will produce an error in the langugae defined in the LANG variable (German in this example).

[root@server1 ~]# asdfasdfsd
-bash: asdfasdfsd: befehl nicht gefunden

 


Different languages for different users

Let's say the system has two users, john.doe (English) and haruto.tanaka (Japanese).

The LANG variable in the /home/john.doe/.profile file can be set to en_US.utf8 (English, USA, Unicode).

LANG=us_EN.utf8

 

The LANG variable in the /home/haruto.tanaka/.profile file can be set to ja_JA.utf8 (Japanese, Japan, Unicode).

LANG=ja_JA.utf8

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c250e3 in the box below so that we can be sure you are a human.