大家都知道通过通过date命令可以查看时间比如

date     查看系统当前时间

date +%Y    显示年份 2017

date +%y    显示年份 17

date +%m    显示月    5

date +%d    显示日    12

date +%w    显示星期    5

date +%H    显示时

date +%M    显示分

date +%S    显示秒

date +%F    显示年-月-日

date +%T    显示 时:分:秒

而有时候系统的时区是错误,比如

[root@localhost ~]# date
Fri May 12 02:03:53 PDT 2017
可以看到自己时区为PDT而大陆一般是东八区,即CST.那么如何更改时区呢?

我们可以通过命令tzselect回车

此时系统会给出很多提示,我们按照提示一步步分别选择 Asia ,China,east China。

这个时候会给出一段信息提示

The following information has been given:

 China
 east China - Beijing, Guangdong, Shanghai, etc.

Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Fri May 12 17:02:55 CST 2017.
Universal Time is now: Fri May 12 09:02:55 UTC 2017.
Is the above information OK?
1) Yes
2) No
#?

此时,我们输入1,选择完毕!

但是时区此时实际上并未修改,因为系统只是根据你的选择给出建议,时区修改还需要我们自己在敲入一段命令

TZ='Asia/Shanghai';export TZ

此时,我们才算是真的修改了时区。

再次查看date

[root@localhost ~]# date
Fri May 12 17:09:46 CST 2017

时区修改完成。