Root Cause of the Problem
When transferring files via FTP between Linux systems (like CentOS/RHEL) and Windows systems, Chinese filenames may appear as garbled characters or question marks. The fundamental cause is character encoding mismatch:
- Windows systems: Typically use GB2312, GBK, or GB18030 encoding for Chinese.
- Linux systems: Modern distributions default to UTF-8 encoding.
- FTP Client/Server: If encoding settings are not unified, garbled characters occur during transfer.
Additionally, if the Linux system does not have the Chinese locale installed or configured correctly, file listings may also display incorrectly.
Solution Overview
Resolving this issue requires action on both the server side (locale configuration) and the client side (FTP tool settings).
Part 1: Configure Chinese Locale on Linux Server
The following steps use CentOS/RHEL as an example to ensure the system correctly recognizes and displays Chinese characters.
1. Check Current Locale
Run these commands in the terminal:
echo $LANG
locale
If the output shows en_US.UTF-8 and lacks zh_CN.UTF-8, you need to install the Chinese language pack.
2. Install Chinese Language Support
For CentOS 6 / RHEL 6 and earlier:
sudo yum groupinstall chinese-support
For CentOS 7 / RHEL 7 and newer:
The old chinese-support group no longer exists. Install the font group first:
sudo yum groupinstall "Fonts"
Then install the Chinese language pack:
sudo yum install langpacks-zh_CN
3. Set System Locale
CentOS 6 / RHEL 6:
Edit the configuration file /etc/sysconfig/i18n:
sudo vi /etc/sysconfig/i18n
Change its content to:
LANG="zh_CN.UTF-8"
LC_ALL="zh_CN.UTF-8"
Or use commands for quick setup:
echo 'LANG="zh_CN.UTF-8"' | sudo tee /etc/sysconfig/i18n
echo 'LC_ALL="zh_CN.UTF-8"' | sudo tee -a /etc/sysconfig/i18n
CentOS 7 / RHEL 7 and newer:
Edit the configuration file /etc/locale.conf:
sudo vi /etc/locale.conf
Change its content to:
LANG="zh_CN.UTF-8"
LC_ALL="zh_CN.UTF-8"
Or use a command for quick setup:
echo 'LANG="zh_CN.UTF-8"' | sudo tee /etc/locale.conf
4. Verify and Apply Changes
Check if the Chinese locale is installed successfully:
locale -a | grep zh_CN
After successful installation, you should see output similar to:
zh_CN.utf8
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
Apply the new locale immediately (for the current session):
source /etc/locale.conf # CentOS 7+
# or
source /etc/sysconfig/i18n # CentOS 6
It is recommended to reboot the system or log out and back in to ensure all services use the new locale settings.
Part 2: Configure FTP Client
Configuring only the server is insufficient. You must ensure the FTP client also uses UTF-8 encoding for transfers.
1. FileZilla (Recommended)
- Open Edit → Settings.
- Go to Transfers → Filename Character Set.
- Select Force UTF-8.
- Click OK.
2. WinSCP
- Open session settings.
- Under Environment → Filename UTF-8 encoding, select On.
- Save settings and reconnect.
3. Xshell / SecureCRT and Other Terminals
If you use FTP via the command line, ensure the terminal encoding is set to UTF-8:
- Open session properties.
- Find the Terminal or Encoding settings.
- Set the character encoding to UTF-8.
- Reconnect.
Part 3: Configure FTP Server (Optional but Recommended)
If you are running an FTP service on the server (like vsftpd), ensure its configuration also supports UTF-8.
For vsftpd:
Edit the configuration file /etc/vsftpd/vsftpd.conf and ensure it contains the following line:
utf8_filesystem=YES
Then restart the vsftpd service:
sudo systemctl restart vsftpd # CentOS 7+
# or
sudo service vsftpd restart # CentOS 6
Troubleshooting
- Problem: Client still shows garbled characters after following the steps.
Solution: Double-check the client encoding settings. This is the most common cause. Ensure the client forces UTF-8 encoding and re-establish the connection. - Problem: Locale settings revert to default after system reboot.
Solution: Confirm you modified the correct configuration file (usei18nfor CentOS 6,locale.conffor CentOS 7+) and that the file content was saved correctly. - Problem: Only some Chinese characters display incorrectly.
Solution: This may be due to missing fonts. Try installing a more complete Chinese font package on the server:sudo yum install wqy-*(WenQuanYi fonts).
Summary
To completely resolve Chinese filename encoding issues in Linux FTP, implement a complete three-step strategy:
- Server Locale: Install and configure the Chinese UTF-8 language pack.
- FTP Client: Force the use of UTF-8 encoding for transfers.
- FTP Server (if self-hosted): Ensure the service configuration supports UTF-8.
After completing these settings, most Chinese filename garbled character issues will be resolved. If the problem persists, check if any proxy or gateway in the network path is modifying the character set.