现象
登录报错
登录时候突然发现提示错误
-bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_CN.UTF-8): No such file or directory -bash: warning: setlocale: LC_COLLATE: cannot change locale (zh_CN.UTF-8): No such file or directory -bash: warning: setlocale: LC_MESSAGES: cannot change locale (zh_CN.UTF-8): No such file or directory -bash: warning: setlocale: LC_NUMERIC: cannot change locale (zh_CN.UTF-8): No such file or directory -bash: warning: setlocale: LC_TIME: cannot change locale (zh_CN.UTF-8): No such file or directory
执行 locale 报错
进入系统后执行 locale 提示错误
locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_COLLATE to default locale: No such file or directory
解决
网上有很多办法
重装字符集
按下面的命令重新安装中文支持
结果:无效
yum -y install kde-l10n-Chinese yum -y reinstall glibc-common
重新生成 locale-archive
按下面的命令重新生成 locale-archive
结果:失败
cd /usr/lib/locale/ mv locale-archive locale-archive.tmpl1 build-locale-archive
提示错误信息
[root@tongfunet]# build-locale-archive /usr/sbin/build-locale-archive: cannot read archive header
最后解决
从好机器上复制 locale-archive 覆盖问题机器
scp root@[好机器]:/usr/lib/locale/locale-archive /usr/lib/locale/locale-archive
问题解决了!!!