linux登录报错LC_ALL: cannot change locale (en_US.UTF-8)

avatar 2022年10月15日18:16:31 评论 519 次浏览

今天安装了一个centos8,安装的时候选择的是中文版,以前都是使用的英文版,英文版的好处就是问题相对要少。今天安装的中文版在远程登录时出现报错信息。

-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
]/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

这里的提示是因为中午版的英语没有,所以需要单独安装一下。解决方法如下:

[root@www.wulaoer.org ~]# dnf install -y langpacks-zh_CN langpacks-en langpacks-en_GB
[root@www.wulaoer.org ~]# cat >/etc/profile.d/locale.sh<<-EOF
> export LANG=en_US.UTF-8
> export LANGUAGE=en_US.UTF-8
> export LC_COLLATE=C
> export LC_CTYPE=en_US.UTF-8
> EOF
[root@www.wulaoer.org ~]# source /etc/profile.d/locale.sh
[root@www.wulaoer.org ~]# exit
logout
Connection to 10.211.55.12 closed.
[wolf@wulaoer.org 🔥🔥🔥🔥 ~ ]$ ssh root@10.211.55.12
root@10.211.55.12's password:
[root@www.wulaoer.org ~]#

重新登录后问题解决,在网上也看了其他的方式,不是修改文件就是安装什么的,过于麻烦,这个相对简单点,我也没有试试其他的,这个方式是解决了。

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: