Home  >  Article  >  Operation and Maintenance  >  How to solve garbled characters in Linux

How to solve garbled characters in Linux

angryTom
angryTomOriginal
2019-11-08 09:42:145482browse

How to solve garbled characters in Linux

garbled characters appear in Linux

How to set the Chinese language of the Linux system, this is what many friends ask when they start using Linux Sometimes, we will encounter a problem, that is, when the terminal input command is echoed, the Chinese characters are displayed as garbled characters. This situation usually occurs because the Chinese language pack is not installed, or there is a problem with the default language set. Taking centos as an example, how to check the language and set and modify the language when operating Linux

How to solve garbled characters in Linux

1. Check the current system language

Log in to the linux system After opening the operation terminal, enter echo $LANG to view the currently used system language. Such as

How to solve garbled characters in Linux

2. Check the installed language pack

How to solve garbled characters in Linux

Check whether there is a Chinese language pack You can enter the locale command in the terminal. If there is zh cn, it means that the Chinese language has been installed.

3. If there is no Chinese language,

can download and install the Chinese language package from the Internet. yum groupinstall chinese-support

How to solve garbled characters in Linux

After installation

enter the localecommand

How to solve garbled characters in Linux

4. How to modify the system language to Chinese

1 Temporarily change the language

If you only temporarily change the language environment of the Linux system, you can Set LANG=language name by inputting, for example, Chinese is LANG=zh_CN.UTF-8

2. Modify the system default language

The above method is to set the system default by modifying Language configuration

such as vi /etc/sysconfig/i18n (note to restart the system after making changes)

How to solve garbled characters in Linux

##5. Other notes

If setting and modifying the Chinese language according to the above method still does not work, pay attention to the encoding selected by your link terminal.

Take xshell as an example, select Chinese or UTF8 for the terminal encoding

How to solve garbled characters in Linux##cmd input chcp 65001 to switch to utf-8 encoding

Centos6 solution:

yum install fontconfig-devel 
yum groupinstall chinese-support

centos7 system:

yum install fontconfig-devel 
yum groupinstall fonts

Recommended:

linux server tutorial

The above is the detailed content of How to solve garbled characters in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn