Centos 6 系统
查看当前系统字符集
echo $LANG
临时修改
LANG=ch_US_UTF-8
[root@test ~]# vim /etc/sysconfig/i18n
LANG=“en_US.UTF-8”
#LANG=“zh_CN.UTF-8”
修改完成后使其生效
. /etc/sysconfig/i18n
Centos 7 系统
在CentOS 7以前的版本下,默认的字符集的路径一般保存在/etc/sysconfig/i18n文件中。但是在CentOS 7版本中,字符集配置文件位于/etc/locale.conf。
在修改该文件之前,可以先查看已经安装的语言包
[root@localhost stress]# locale -a
修改字符集
[root@localhost stress]# vim /etc/locale.conf
#LANG=“zh_CN.UTF-8”
LANG=“en_US.UTF-8”
修改后使其生效
[root@localhost stress]# . /etc/locale.conf
确认是否已修改
[root@localhost stress]# locale
命令修改方法:
[root@localhost ~]# cat /etc/locale.conf
LANG=zh_CN.UTF-8
[root@localhost ~]# localectl set-locale LANG=en_US.UTF-8
[root@localhost ~]# cat /etc/locale.conf
LANG=en_CN.UTF-8