User Tools

Site Tools


tips:how-to-disable-utf-8-in-console

How to disable UTF-8 in console

The purpose of this page is to describe how UTF-8 can be disable in Ubuntu / Debian console. At least Ubuntu releases starting from Dapper have UTF-8 enabled by default after a clean install has been done. Checking the current status is simple:

$ echo $LANG
en_US.UTF-8

If the result is anything else than en_US.UTF-8 then UTF-8 shouldn't be enabled and there's no point in reading the rest of this page unless generating locales is the point of interest.

Check /etc/default/locale and /etc/environment as root (so that you can edit it). One of these files will contain line similar to these, LANG is the one you are searching for:

LANG="en_US.UTF-8"
LANGUAGE="en_FI:en"

The LANGUAGE setting depends of what you have selected during the beginning of the install process and usually doesn't nee to be changed. Remove UTF-8 from the LANG setting so that after editing that line will look like:

LANG="en_US"

Save the changes and close the file. Remember to check both files!

Next it's time to generate some new locales because en_US doesn't probably exist yet. Open /var/lib/locales/supported.d/local and if will look like:

en_US.UTF-8 UTF-8

and make it look like:

en_US ISO-8859-1
en_US.UTF-8 UTF-8

Also any other locale that needs to be generated should be added to that file. For example Finnish users might want to have fi_FI ISO-8859-1 in there too. Remeber to save the file after editing.

Now it's time to generate those new locales. As usual, run the following as root.

$ locale-gen
Generating locales...
...
Generation complete.

local-gen will list all locales included in /var/lib/locales/supported.d/local and generate those if necessary. Finally just log out and back in again. UTF-8 should now be disable. That can be checked in the same way we started:

$ echo $LANG
en_US

Ubuntu 12.04 (and possibly also Debian) appendix

(status as of 5.8.2012)
A change done in January 2012 that was introduced in Ubuntu 12.04 causes the file .pam_environment to be created to the user home directory usually when logging in X. The content of that file is created from /etc/default/locale but .UTF-8 is forced after each entry even if the original didn't contain such. This results UTF-8 getting forced even if it has been disabled in /etc/default/locale. The easiest way to fix this is to edit (as root) /usr/share/language-tools/save-to-pam-env and add the following before "exit 0" near the end of the file:

sed -i -e 's:\.UTF-8::g' "$homedir/.pam_environment"

Log out and back in again. Now the .pam_environment shouldn't anymore contain traces of UTF-8.

Bug report in Launchpad: https://bugs.launchpad.net/ubuntu/+source/accountsservice/+bug/1033698

tips/how-to-disable-utf-8-in-console.txt · Last modified: 07.08.2012 01:37 by vergo