- 1 Introduction
- 2 Enabling necessary locales
- 3 Setting system wide locale
- 4 Setting per user locale
- 5 Troubleshooting
Locales are used in Linux to define which language the user uses. As the locales define the charset which the user uses as well, setting up the correct locale is especially important if the language contains non-ASCII characters.
Locales are defined as following:
In this howto we're setting up a system that uses the en_US.UTF-8 locale, but you can follow this article easily if you want to setup another locale.
Enabling necessary locales
First you have to enable the locales you want being supported by your system. To enable or disable them, the file /etc/locale.gen is used. It contains every locale you can enable, and you have just to uncomment lines you want to do so.
As we want to setup an english UTF-8 conform system, we want to enable en_US.UTF-8. But for compatibility to programs that don't support UTF-8 yet, it's recommended to support any other locale, prefixed with en_US as well. Having this in mind, we enable this set of locales:
en_US.UTF8 UTF-8 en_US ISO-8859-1
After you've enabled the necessary locales, you have to run locale-gen as root to update them:
# locale-gen Generating locales... en_US.UTF-8... done en_US.ISO-8859-1... done Generation complete.
Note: Though it's most likely just one language you use on your computer it can be helpful or even necessary to enable other locales as well. For example if you're running a multi-user system with users that don't speak en_US, they won't be happy until their individual locale is at least supported by your system.
Setting system wide locale
To define which locale should be used by the system, you can easily add your locale to your /etc/rc.conf file. As we've just added ISO-8859 support just for (backward-)compability, we add en_US.utf-8 here:
The system wide locale will be updated after rebooting your computer.
Setting per user locale
As we discussed earlier, some users might want to define a different locale than the system ones. In this case, you can export LC_ALL in your ~/.bashrc. For example you can use the en_US.iso8859 locale, though there is not advance of using it.
Your locales will be updated as soon as you re-source your ~/.bashrc. This happens on login or alternatively you can type:
$ source ~/.bashrc
How can I obtain the available locale names?
You can get the correct names of all available locales with this command:
$ locale -a
How can I see which locale I am using?
Which locale is currently in use is viewable simply by typing:
My terminal doesn't support UTF-8 characters
Unfortunately some terminals don't support UTF-8. In this case, you have to use different terminal.
List of terminals that support UTF-8:
- urxvt (rxvt-unicode)
Note: This list may be incomplete.
xterm doesn't support UTF-8 characters for me
xterm only supports UTF-8 if you run it as uxterm or xterm -u8.