linux - 设置LINUX 的时区( set linux time zone) 和locales
访问量: 4384
很多时候,你的LINUX时间显示的不对,不是时间不对,而是时区错了。 (most of the time, the root cause you found the time is not correct is that your linux is not setup with the correct timezone)
解决办法: for short: dpkg-reconfigure tzdata
refer to: http://www.christopherirish.com/2012/03/21/how-to-set-the-timezone-on-ubuntu-server/
You can check your current timezone by just running
$ date
Thu Mar 21 18:02:49 MST 2012
Or checking the timezone file at
$ more /etc/timezone
US/Arizona
So to change it just run
$ sudo dpkg-reconfigure tzdata
And follow on screen instructions. Easy.
修改 locale的办法
: 参考: https://www.douban.com/note/362250557/
1. 先看该系统中的所有有效locale:
$ locale -a
$ locale -a C C.UTF-8 POSIX en_US en_US.iso88591 en_US.utf8
所以,我们要生成它:
$ sudo locale-gen zh_CN.UTF-8 Generating locales... zh_CN.UTF-8... done Generation complete.
这个时候,再次的 $ locale -a
$ locale -a C C.UTF-8 en_US en_US.iso88591 en_US.utf8 POSIX zh_CN.utf8
2. $ sudo locale-gen en_US en_US.UTF-8
Generating locales...
en_US.ISO-8859-1... done
en_US.UTF-8... up-to-date
Generation complete.
3. $ sudo dpkg-reconfigure locales
4. $ sudo vim /etc/default/locale (下面的东东可以去掉? 2018-4-18 不确定. 保证执行第五点就可以了)
1 # Created by cloud-init v. 0.7.5 on Mon, 12 Feb 2018 03:28:35 +0000 2 LANG="en_US.UTF-8" 3 LANGUAGE="en_US:en"
5. 在 ~/.bashrc中, 添加下面的变量(解决git log无法显示中文的问题 )
export LESSCHARSET=utf-8
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8