How to solve the garbled characters of Chinese file names under linux command line
First, query the supported encodings:
Locale-a
If you don't have the code you need, such as Zh_cn.utf8
Root run: #dpkg-reconfigure locales
Select the encoding you want, select it with a space, and choose multiple options. tab select "OK" and enter.
Default encoding Selection Zh_cn.utf8
Install the encoding you need.
Method One:
Modify the/etc/sysconfig/i18n file
Change the lang= "en_US" inside to GB2312.
To restart the machine.
Without restarting the method, directly
# lang= "GB2312"
And then we can.
Modify i18n just to restart the active
Method Two:
#vi ~/.bash_profile
Lang=zh_cn. GB18030
Language=zh_cn.gb18030:zh_cn.gb2312:zh_cn
Export LANG LANGUAGE
This will be able to input and display the Chinese in the terminal, and the shell script in the original Chinese display garbled problem also solved
Method Three:
Modify/etc/sysconfig/i18n
The 1th sentence lang= "ZH_CN. UTF-8 "changed to Lang=" ZH_CN. GB18030 "
Method Four:
Modify/etc/sysconfig/i18n
Language= "Zh_CN.GB18030:zh_CN.GB2312:zh_CN"
Supported= "ZH_CN. GB18030:zh_CN:zh:en_US. Utf-8:en_us:en "
Sysfont= "Lat0-sun16"
Sysfontacm= "8859-15"
Method Five:
cd/etc/sysconfig/
CP i18n I18n.bak #备份i18n文件
echo "" >i18n
VI i18n #加入以下内容
Lang= "ZH_CN. GB18030 "
Language= "Zh_CN.GB18030:zh_CN.GB2312:zh_CN"
Supported= "ZH_CN. GB18030:zh_CN:zh:en_US. Utf-8:en_us:en "
Sysfont= "Lat0-sun16"
Chinese display is normal after reconnecting
Method Six:
Modify/etc/profile,
Comment out
Export Lc_all=c
Increase
Export Term=xterm-color
Export lc_ctype=zh_cn.gb2312
Export Lang=en_us. UTF-8
How to solve the garbled characters of Chinese file names under linux command line