CentOS 7 设置系统语言为英文并解决 cannot change locale 问题

首次安装Cent OS 7.6时,将系统语言设置成了中文。后续学习和使用过程中却发现种种不便,甚至有翻译错误。为锻炼自己的英文能力,所以将系统语言设置问英文。

编辑 locale 配置文件,将 LANG=zh_CN.UTF8 改为 LANG=en_US.UTF8 后保存

# vi /etc/locale.conf

LANG=en_US.UTF8

重启系统后,已经改为英文语言了。但却出现另一个问题:

-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

解决方法如下

# vi /etc/environment

添加两行内容

LANG=en_US.utf-8
LC_ALL=

在运行命令

# source /etc/environment

# localedef -v -c -i en_US -f UTF-8 en_US.UTF-8

最后一条命令好像执行失败了,不过没影响。再次重启进入系统后,一切就正常了。

参考资料:

https://www.jianshu.com/p/65622959d307

https://segmentfault.com/a/1190000004378075

http://www.cnblogs.com/xlmeng1988/archive/2013/01/16/locale.html

https://stephenzhou.net/2018/09/19/linux-locale-issue/

转载于:https://www.cnblogs.com/walixz/p/10353048.html

你可能感兴趣的:(CentOS 7 设置系统语言为英文并解决 cannot change locale 问题)