1.配置 locale-gen
sudo locale-gen zh_CN.UTF-8
检查现在中文是否正常,不正常则继续
2.配置语言环境变量
在终端执行下面语句
export LANG=en_US.UTF-8
export LANGUAGE=
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC=zh_CN.UTF-8
export LC_TIME=zh_CN.UTF-8
export LC_COLLATE="en_US.UTF-8"
export LC_MONETARY=zh_CN.UTF-8
export LC_MESSAGES="en_US.UTF-8"
export LC_PAPER=zh_CN.UTF-8
export LC_NAME=zh_CN.UTF-8
export LC_ADDRESS=zh_CN.UTF-8
export LC_TELEPHONE=zh_CN.UTF-8
export LC_MEASUREMENT=zh_CN.UTF-8
export LC_IDENTIFICATION=zh_CN.UTF-8
export LC_ALL=
3.如果遇到-bash: warning: setlocale: LC_NUMERIC: cannot change locale (zh_CN.UTF-8)
提示,则需在~/.bashrc
文件或~/.profile
文件末尾添加如下代码
export LC_CTYPE="en_US.UTF-8"
4.重新载入.bashrc文件,必要时退出当前终端,重新登录
source ~/.bashrc
5.一般情况只执行3和4问题就解决了。
6.命令行写不了中文的情况,先按照上面步骤操作,然后退出当前终端,重新进入就好了。
参考:https://blog.csdn.net/weixin_39198406/article/details/82177944
网友评论