Locale and setlocale LC error messages
You may receive the following errors when logging in to your CentOS or Red Hat Enterprise Linux (RHEL) system via SSH or at the console:
-bash: warning: setlocale: LC_CTYPE: cannot change locale (us): No such file or directory -bash: warning: setlocale: LC_COLLATE: cannot change locale (us): No such file or directory -bash: warning: setlocale: LC_MESSAGES: cannot change locale (us): No such file or directory -bash: warning: setlocale: LC_NUMERIC: cannot change locale (us): No such file or directory -bash: warning: setlocale: LC_TIME: cannot change locale (us): No such file or directory
When running the locale command, you may see these additional errors:
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_ALL to default locale: No such file or directory
These errors are caused by the system language being set to an unrecognized locale.
Check the /etc/sysconfig/i18n file to see what the system language is set to:
cat /etc/sysconfig/i18n
The LANG variable in the /etc/sysconfig/i18n file needs to be set to a valid locale – in some cases, LANG is set to “us” which is not recognized by setlocale, leading to the previously listed errors.
Run the following command to find the valid locales on your system, and compare that to the LANG variable in the /etc/sysconfig/i18n file.
locale -a
Change your system language to a valid entry as provided by the locale -a command.
Edit the /etc/sysconfig/i18n file:
sudo vi /etc/sysconfig/i18n
Change LANG to a valid locale, such as en_US.UTF-8:
LANG="en_US.UTF-8"
Reload the i18n file:
sudo source /etc/sysconfig/i18n
Check the system locale variable, which should now be the same as what you entered in /etc/sysconfig/i18n:
echo $LANG
Additional troubleshooting
Issuing the locale command at the console will show you what that current console language is set to:
locale
The following sample output from the locale command shows the system LANG is set to “us,” which is the cause of the error messages. Follow the directions above to change “us” to “en_US.UTF-8” as detailed above.
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_ALL to default locale: No such file or directory LANG=us LC_CTYPE="us" LC_NUMERIC="us" LC_TIME="us" LC_COLLATE="us" LC_MONETARY="us" LC_MESSAGES="us" LC_PAPER="us" LC_NAME="us" LC_ADDRESS="us" LC_TELEPHONE="us" LC_MEASUREMENT="us" LC_IDENTIFICATION="us" LC_ALL=
Hi there,
Steve first class you have just sorted the language problem I had with a Dedibox server. Much appreciated.
Regards
Stevie Shaw
Great! Glad to hear that this helped you out.
Steve
great, i had some issue with centos 6.6, it works charm
Thanks you very much ! CentOS suxx with this uncomplete installer….
$ cat /etc/locale.conf
LANG=”en_US.UTF-8″
$ 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
POSIX