-bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_CN.UTF-8mb4): No such file or director...

前几天登录服务器发现出现了这些个警告,一直没时间去处理他,今天难得有空,处理一下并记录下来,希望可以帮助到有需要的朋友。

警告信息如下:

Last login: Tue May 21 18:54:23 2019 from 192.168.1.139
-bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_CN.UTF-8mb4): No such file or directory
-bash: warning: setlocale: LC_COLLATE: cannot change locale (zh_CN.UTF-8mb4): No such file or directory
-bash: warning: setlocale: LC_MESSAGES: cannot change locale (zh_CN.UTF-8mb4): No such file or directory
-bash: warning: setlocale: LC_NUMERIC: cannot change locale (zh_CN.UTF-8mb4): No such file or directory
-bash: warning: setlocale: LC_TIME: cannot change locale (zh_CN.UTF-8mb4): No such file or directory

思路:

根据警告信息,判断是字符集的问题。

在实际工作环境下,Linux中不建议使用中午。

首先简单介绍一下字符集的概念:

简单地说,字符集(Character set)是多个字符的集合,字符集种类较多,每个字符集包含的字符个数不同,常见字符集名称:ASCII字符集、GB2312字符集、GBK字符集、UTF-8字符集等。

在CentOS 7以前的版本下,默认的字符集的路径一般保存在/etc/sysconfig/i18n文件中。但是在CentOS 7版本中,字符集配置文件位于/etc/locale.conf。

在修改该文件之前,可以先查看已经安装的语言包:

列出所有已安装的语言包

# locale -a

查看系统使用的字符集

# locale

[root@localhost ~]# locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

 

修改成如下字符集

# cat /etc/locale.conf

[root@localhost ~]# cat /etc/locale.conf  
NG="en_US.UTF-8"

 

使配置生效

# source /etc/locale.conf  

 下次登录服务器就不会出现上面的问题了

参考博客:

https://www.cnblogs.com/chai-/p/9592823.html

https://yq.aliyun.com/articles/512954

转载于:https://www.cnblogs.com/djlsunshine/p/10902308.html

你可能感兴趣的:(-bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_CN.UTF-8mb4): No such file or director...)