Linux时区修改

【查看时区】
方法A:
[root@localhost ~]# date
Wed May 12 00:14:36 CST 2021
[root@localhost ~]# timedatectl
Local time: Wed 2021-05-12 00:18:00 CST
Universal time: Tue 2021-05-11 16:18:00 UTC
RTC time: Tue 2021-05-11 08:16:59
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a

方法B:
[root@localhost ~]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 35 Mar 12 16:14 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai

【修改时区】
方法A:tzselect:执行tzselect命令-->选择Asia-->选择China-->选择east China - Beijing, Guangdong, Shanghai, etc-->然后输入1。

方法B:修改配置文件来修改时区

  1、修改/etc/sysconfig/clock ZONE=Asia/Shanghai

  2、rm /etc/localtime     删除/etc/localtime重新链接

  3、链接到上海时区文件 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

  执行完上述过程后,重启机器,即可看到时区已经更改。

  这些都需要重启才能生效

方法C:
sudo timedatectl set-timezone 'Asia/Shanghai'

posted @ 2021-06-14 01:31  双叶幼稚园IT协会  阅读(296)  评论(0编辑  收藏  举报