-bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_US.UTF-8): No such file or directory -...

前几天登录服务器发现出现了这些个警告,一直没时间去处理他,今天难得有空,处理一下并记录下来,希望可以帮助到有需要的朋友。

警告信息如下:

Last login: Wed Sep  5 13:02:29 2018 from 10.0.0.1
-bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_COLLATE: cannot change locale (zh_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_MESSAGES: cannot change locale (zh_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_NUMERIC: cannot change locale (zh_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_TIME: cannot change locale (zh_US.UTF-8): No such file or directory

 

思路:

根据警告信息,我判断是字符集的问题。

排查:

[root@linux-node1 ~]# cat /etc/sysconfig/i18n 
LANG="zh_US.UTF-8"
SYSFONT="latarcyrheb-sun16"

 

 

[root@linux-node1 ~]# locale
LANG=zh_US.UTF-8
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C

 

没有报什么错误!

然后我就上网百度一下中文字符集的编码

结果:

名字写错了,根本就没有zh_US.UTF-8这种编码方式,对应的是zh_CN.UTF-8,最后在/etc/sysconfig/i18n中把字符集改一下,解决了这个问题。

一般linux系统的语言环境设置成:export LANG=zh_CN.UTF-8,代表中国人使用的unicode字符集

 

转载于:https://www.cnblogs.com/chai-/p/9592823.html

你可能感兴趣的:(-bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_US.UTF-8): No such file or directory -...)