Fix Locale Setting In Ubuntu Server 12.04

Fix Locale Setting In Ubuntu Server 12.04

There seems to be a bug in Ubuntu 12.04 with setting locales for users, the root locales are set but this doesn't seem to filter down to individual user accounts. This might not be a problem for you until you ssh into your server. And by the way this seems to be affecting Debian variants, I haven't checked Debian but my Raspberry Pi which are running Raspbian, a variant of Debian, are affected too. This bug does not affect the desktop version of this OS, only if installed on server (minimal install).

Now I use three different OS to ssh with windows Putty, OSX terminal and a Linux terminal and I want the same locale encoding on all three.

As a programmer I like to use UTF-8 encoding for my HTML, PHP, JS and CSS files so this is the encoding default for all my systems.

I only really noticed this when I was using ssh on my iPad and Midnight Commander on the server and the terminal had strange letters where lines should be but when I used mc as root everything was the way it should be! So I knew I had a problem so I googled for a solution and tried several, which didn't work, and come to the right one eventually.

So with that said here is how I fixed it:

First we need to see what locale settings the user has set so in a terminal enter


If this shows what is below then you have this bug.


Now I use British English so in '~/.bashrc', add at the bottom

export LANG="en_GB.UTF-8"
export LANGUAGE="en_GB:en"
export LC_CTYPE="en_GB.UTF-8"
export LC_NUMERIC="en_GB.UTF-8"
export LC_TIME="en_GB.UTF-8"
export LC_COLLATE="en_GB.UTF-8"
export LC_MONETARY="en_GB.UTF-8"
export LC_MESSAGES="en_GB.UTF-8"
export LC_PAPER="en_GB.UTF-8"
export LC_NAME="en_GB.UTF-8"
export LC_ADDRESS="en_GB.UTF-8"
export LC_TELEPHONE="en_GB.UTF-8"
export LC_ALL=

Now this has to be done for ever user so put this code in '/etc/skel/.bashrc' then every new user will have this default encoding set.

For more info on locales

If anyone has another way that works please feel free to post it.

20/04/2014 08:29:00 Shaun Freeman Filed Under: Linux Debian, Linux, Raspberry Pi, Server, Ubuntu

Twitter Feed
Shaun Freeman @Zendmaster

Shaun Freeman @Zendmaster

I liked a @YouTube video Patrick Stewart talks about meeting Sting on the set of DUNE (Funny to the EXTREME)

Shaun Freeman @Zendmaster

I added a video to a @YouTube playlist Anonymous - This will Change Everything You Know... (2018-2019)

Shaun Freeman @Zendmaster

I added a video to a @YouTube playlist Will Artificial Intelligence Take Over The World?

Shaun Freeman @Zendmaster

I liked a @YouTube video Frank Abagnale: "Catch Me If You Can" | Talks at Google

Shaun Freeman @Zendmaster

I liked a @YouTube video ETS2: Special Transport DLC Trailer