通过xshell等工具登录centos出现下面warnning
-bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
解决方案:
在tee /etc/environment中编辑下面内容:
'EOF'
LANG=en_US.utf-8
LC_ALL=
EOF
保存后,再source配置
source /etc/environment
然后退出再进入就可以发现不会啦。
如果还有问题,则再输入
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
至于原因
是因为我们已经设置了默认地区_语言。字符集为en_US.UTF-8,但是系统中没有定义这个问题。
可以通过运行 locale -a 查看系统当前支持的locale定义
参考:
https://segmentfault.com/a/1190000004378075
https://www.xuecaijie.com/linux/201.html