Ubuntu command line displays Chinese

Our Ubuntu server has always had problems displaying Chinese with the command line. Finding information on the Internet and installing zhcon still cannot solve our problem. Therefore, the possible reasons are investigated here and recorded.

Solution###

Put the following settings in ~/.bashrc, and then execute source ~/.bashrc:

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="en_US.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=

The most important one is the last setting LC_ALL, because its default setting is LC_ALL=C, C means to override the value of LANG and all LC_* variables and set it to the system default value. Therefore, if this item is left blank, the custom setting can be adopted.

Reference content###

  1. https://wiki.archlinux.org/index.php/Locale_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

Recommended Posts

Ubuntu command line displays Chinese
ubuntu command line search
Ubuntu Server Chapter 2 Command Line Basics
Ubuntu16.04 common command notes
ubuntu set Chinese font
Use the command line to detect the Ubuntu version method
Ubuntu 20.04 Chinese input method support
Centos8-graphical interface and command line switching
ubuntu20.04 Chinese input method installation steps
Python Chinese encoding setting under ubuntu
Ubuntu 19.1 installation and configuration Chinese environment