HostOnNet Blog

locale: Cannot set LC_CTYPE to default locale: No such file or directory

When i login to a server, i get following error

-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

To verify en_US.UTF-8 is available on the system, run locale -a

root@testing:~# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
en_GB.utf8
root@testing:~#

On this server en_US.UTF-8 is not installed. To enable this, run

dpkg-reconfigure locales

You will get screen with all available locales, select the one you need to install, in this cause i selected en_US.UTF-8

On next screen, you will be asked to select default locale (language) for your system, select the one you want.

Now log off and re connect. You should not get any error. Verify locale with

root@testing:~# locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
root@testing:~# 

Posted in Linux