背景
今天刚买了一个华为云服务器,刚登录上去就有如下报错
Welcome to Huawei Cloud Service
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
系统环境是 CentOS Linux release 7.9.2009 (Core)
此时如果我们执行locale
命令,可能也会看到类似如下的报错
[root@node-02 ~]# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=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=
解决
该问题的原因是字符集的配置问题,按照如下方法重新配置下
cat /etc/locale.conf
LC_ALL="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LANG="en_US.UTF-8"
source /etc/locale.conf
上面的内容修改完之后,重新登录一下,报错消失