Background
Using a USB flash drive to the Windows host, Linux host files or often, but sometimes the file name is in Chinese,
To the Linux machine will be garbled, the choice is also very troublesome, recently just met, write down the solution.
Environment
Linux
cat /etc/redhat-7.2. 1511 (Core) [[email protected]echo $LANGen _us. UTF-8[[email protected]
Windows Xshell
Problem
TXT file is used xftp directly from Windows dragged over, on the Linux machine display garbled.
[[Email protected] ~]# lltotal801272-RW-------.1Root root996Dec the the: Aboutanaconda-KS.CFGDRWXR-xr-x.6Root root -Dec + -: -cmake-3.7.1-linux-x86_64-rw-r--r--.1Root root30679418Dec + -: -cmake-3.7.1-linux-x86_64.Tar. GZDRWXR-xr-x.4Root root inDec + .: thellvm-src-rw-r--r--.1Root root779956643Jan1 -: +Llvm-src.Tar. GZDRWXR-xr-x.8 + + 4096TheTen -Vim74-rw-r--r--.1Root root9843297Dec + to:Genevavim-7.4.Tar. bz2-rw-r--r--.1Root root975JanTen .: on??????? Regexp.txt[[email protected]-base ~]#
Solve
In general, this problem is the encoding character set of the file, the shell coded character set, the Xshell coded character set mismatch, the matching is possible.
Interim measures
1) Simplified Chinese Windows generally use the GB character set, where Xshell is set to GBK
2)
Linux hosts
[Email protected] ~]# export lang=ZH_CN.GBK
Try again, you can display Chinese normally.
[[Email protected] ~]# ll Total dosage801272-RW-------.1Root root996December the the: Aboutanaconda-KS.CFGDRWXR-xr-x.6Root root -December + -: -cmake-3.7.1-linux-x86_64-rw-r--r--.1Root root30679418December + -: -cmake-3.7.1-linux-x86_64.Tar. GZDRWXR-xr-x.4Root root inDecember + .: thellvm-src-rw-r--r--.1Root root779956643January1 -: +Llvm-src.Tar. GZDRWXR-xr-x.8 + + 4096AugustTen -Vim74-rw-r--r--.1Root root9843297December + to:Genevavim-7.4.Tar. bz2-rw-r--r--. 1 root root 975 January : regexp.txt practice
However, the above settings are only valid for the current shell connection, and the newly opened shell is still in the original settings.
Permanent effect
1) Xshell Property settings
2) Linux environment variable settings
[Email protected] ~]# Vim/etc/profile
Append at end
Export LANG=ZH_CN.GBK
You can do it.
However...... I found that the USB stick inserted on the Linux machine still does not correctly recognize the Chinese directory, the Chinese file
There are other strange, that is, when mounting a USB stick set the next character sets
Mount -o iocharset=gbk/dev/sdb4/mnt
This setting is generally almost solved.
However, this operation caused the import of Xxx.sql file when the database Chinese garbled problem, pending research ...
Xshell Connection CentOS 7.2 Display Chinese garbled problem solving method