红联Linux门户
Linux帮助

申请的阿里云主机ubuntu系统无法显示中文及locale设置

发布时间:2017-08-29 10:20:50来源:linux网站作者:wzc0066
系统ubuntu 16.04,中文的文件名也无法显示,因为中文包没安装,安装如下:
sudo apt-get -y install language-pack-zh-hans
sudo apt-get install zh-autoconvert
sudo apt-get install zhcon
很多年没折腾中文显示的问题了,记录一下。
 
关于locale设置问题,执行apt时通常会提示如下错误:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "zh_CN.UTF-8",
LC_MONETARY = "zh_CN.UTF-8",
LC_ADDRESS = "zh_CN.UTF-8",
LC_TELEPHONE = "zh_CN.UTF-8",
LC_NAME = "zh_CN.UTF-8",
LC_MEASUREMENT = "zh_CN.UTF-8",
LC_IDENTIFICATION = "zh_CN.UTF-8",
LC_NUMERIC = "zh_CN.UTF-8",
LC_PAPER = "zh_CN.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
按如下步骤解决:
$ sudo apt-get install locales
编辑文件/etc/locale.gen,找到# en_US.UTF-8 UTF-8,去掉前面的井号;
$ sudo locale-gen en_US.UTF-8
$ sudo update-locale en_US.UTF-8
编辑~/.bashrc,在最后面增加一行并通过source命令使其生效:
export LC_ALL=C
$ source .bashrc
或者修改/etc/default/locale:
$ cat /etc/default/locale
LC_ALL="en_US.UTF-8"
到此应该能解决错误信息提示问题,但是系统可能无法显示中文,所以如果希望正确显示中文,需要安装中文包:
$ sudo apt-get install language-pack-zh-hans
 
本文永久更新地址:http://www.linuxdiyf.com/linux/32446.html