方法一
- 检查现在的时区
[root@localhost ~]# timedatectl
Local time: Tue 2020-03-31 16:35:23 CST
Universal time: Tue 2020-03-31 08:35:23 UTC
RTC time: Tue 2020-03-31 08:35:23
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
- 更改时区
- 列出所有可用时区
[root@localhost ~]# timedatectl list-timezones
…
Asia/Samarkand
Asia/Seoul
Asia/Shanghai
Asia/Singapore
Asia/Srednekolymsk
…
- 更改时区
[root@localhost ~]# timedatectl set-timezone Asia/Shanghai
方法二
仅针对个别用户起效。
- 选择时区
tzselect
选择时给出选项的数字编号。
- 生成环境变量配置
上边的命令会生成如下内容
TZ='Asia/Shanghai'; export TZ
-
把生成的环境变量配置加入登陆用户的~/.bash_profile
-
注销重新登陆