Ubuntu – Setting locale in Ubuntu 12.04 (openvz)

environment-variableslocalizationopenvzUbuntuutf-8

I have a fresh installation of Ubuntu 12.04 as virtual openVZ guest.
The defined locale for LC_* in basic setup is POSIX.

I'd like to change this to en_US.UTF-8.
So I installed language_pack_en_base and language_pack_en, ran dpkg-reconfigure locales and added the following lines to /etc/environment and /etc/default/locale:

LANG=en_US.UTF-8
LC_CTYPE=C
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8

But after restarting the virtual machine the output of locale is:

LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

What else can I do to set en_US.UTF-8 as locale for this server?

Best Answer

In my case when logging in with ssh none of the usual default locale or environment variable settings seemed to work. It was because I had disabled PAM session control in sshd configuration.

Make sure you have set

UsePAM yes 

in your /etc/ssh/sshd_config file