出现这个情况一般是由于没有安装中文语言包,或者设置的默认语言有问题导致的。
查看当前语言环境
echo $LANG
发现为
zh_TW.UTF-8
但是中文语言包没安装或没启用,就会出现乱码
输入LANG=en_US
设置显示为英文,此命令即时生效,但不能永久生效,永久生效看下面。
此时,再次输入命令就可以看到英文报错信息了
如果一定需要中文提示,可以这样安装:
yum groupinstall chinese-support
设置本地默认语言环境
vim /etc/locale.conf
加入
LANG=“zh_TW.UTF-8”
即时永久生效
source /etc/locale.conf
输locale
可以查看本地语言环境
LANG=zh_TW.UTF-8
LC_CTYPE="zh_TW.UTF-8"
LC_NUMERIC=zh_TW.UTF-8
LC_TIME=zh_TW.UTF-8
LC_COLLATE="zh_TW.UTF-8"
LC_MONETARY=zh_TW.UTF-8
LC_MESSAGES="zh_TW.UTF-8"
LC_PAPER=zh_TW.UTF-8
LC_NAME="zh_TW.UTF-8"
LC_ADDRESS="zh_TW.UTF-8"
LC_TELEPHONE="zh_TW.UTF-8"
LC_MEASUREMENT=zh_TW.UTF-8
LC_IDENTIFICATION="zh_TW.UTF-8"
LC_ALL=
注意,我这变语言环境是台湾繁体,中文简体应将TW改为CN