Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of modifying system Code under Linux

Shulou Source: shulou.com Published: 2022-06-03 01:10:16 09月24日 Update

Linux system installation, found that Chinese display garbled. Because the system code is en_US. UTF-8, it should be changed to support the code of Chinese (i.e. zh_CN. UTF-8)

The operation record is as follows:

0) Chinese language pack must be installed in the system

[root@xqsj-beta ~]# yum -y groupinstall chinese-support

1) Check the Linux system code

Check linux system code to see if the system supports Chinese. Enter the command: locale in the linux system terminal and you will see the printed system code information.

[root@xqsj-beta ~]# locale

LANG=en_US.UTF-8

LC_CTYPE="en_US.UTF-8"

LC_NUMERIC="en_US.UTF-8"

LC_TIME="en_US.UTF-8"

LC_COLLATE="en_US.UTF-8"

LC_MONETARY="en_US.UTF-8"

LC_MESSAGES="en_US.UTF-8"

LC_PAPER="en_US.UTF-8"

LC_NAME="en_US.UTF-8"

LC_ADDRESS="en_US.UTF-8"

LC_TELEPHONE="en_US.UTF-8"

LC_MEASUREMENT="en_US.UTF-8"

LC_IDENTIFICATION="en_US.UTF-8"

LC_ALL=

Modify system code to support Chinese

Method 1:

(2) Edit system code file

[root@xqsj-beta ~]# vim /etc/sysconfig/i18n

LANG="zh_CN.UTF-8"

[root@xqsj-beta ~]# source /etc/sysconfig/i18n

Check the system code again and find that it has been changed to support Chinese code

[root@xqsj-beta ~]# locale

LANG=zh_CN.UTF-8

LC_CTYPE="zh_CN.UTF-8"

LC_NUMERIC="zh_CN.UTF-8"

LC_TIME="zh_CN.UTF-8"

LC_COLLATE="zh_CN.UTF-8"

LC_MONETARY="zh_CN.UTF-8"

LC_MESSAGES="zh_CN.UTF-8"

LC_PAPER="zh_CN.UTF-8"

LC_NAME="zh_CN.UTF-8"

LC_ADDRESS="zh_CN.UTF-8"

LC_TELEPHONE="zh_CN.UTF-8"

LC_MEASUREMENT="zh_CN.UTF-8"

LC_IDENTIFICATION="zh_CN.UTF-8"

LC_ALL=

methodology II

(3) The declaration of path variables is added to the system environment variable file, which works on the whole system.

[root@xqsj-beta ~]# vim /etc/profile //Add the following at the bottom of the file

........

LC_ALL="zh_CN.UTF-8"

export LANG="zh_CN.UTF-8"

[root@xqsj-beta ~]# source /etc/profile

[root@xqsj-beta ~]# locale

---------------------------------------------------------------------------------------------

Found a problem with Chinese edited under Windows and displayed as garbled characters under Linux.

This is because Windows default encoding is GBK, while Linux default encoding is UTF-8.

To fix this, you need to change the default encoding for Linux to GBK.

[root@xqsj-beta ~]# vim /etc/sysconfig/i18n

LANG="zh_CN.GBK"

SUPPORTED="zh_CN.UTF-8:zh_CN:zh"

SYSFONT="latarcyrheb-sun16"

[root@xqsj-beta ~]# source /etc/sysconfig/i18n

[root@xqsj-beta ~]# locale

or modify system environment variables directly.

[root@xqsj-beta ~]# vim /etc/profile

......

export LC_ALL="zh_CN.GBK"

export LANG="zh_CN.GBK"

[root@xqsj-beta ~]# source /etc/profile

[root@xqsj-beta ~]# locale

Tags: System coding Chinese support variables files methods garbled environment problem check function information content again command bottom terminal language path Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn MariaDB OPPO Reno Redmi