检查当前的时区设置
使用timedatectl
命令显示当前的时区和时间:
$ timedatectl Local time: Tue 2015-06-06 10:27:34 PST Universal time: Tue 2015-06-06 18:27:34 UTC RTC time: Tue 2015-06-06 18:27:35 Time zone: Canada/Yukon (PST, -0800) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no
另一种选择在Ubuntu 18.04系统上检查当前的时区,如果上述命令由于某种原因失败,则检查/etc/localtime
符号链接:
$ ls -l /etc/localtime lrwxrwxrwx 1 root root 32 Jun 6 10:27 /etc/localtime -> /usr/share/zoneinfo/Canada/Yukon
显示所有可用的时区
$ timedatectl list-timezones
可以使用grep过滤结果:
$ timedatectl list-timezones | grep -i europe Europe/Amsterdam Europe/Andorra Europe/Astrakhan Europe/Athens Europe/Belgrade Europe/Berlin Europe/Bratislava Europe/Brussels Europe/Bucharest Europe/Budapest Europe/Busingen ... Europe/Zurich
时区列表保存在/usr/share/zoneinfo/
目录。
在Ubuntu上更改时区
设置timedatectl同样使用timedatectl命令
$ sudo timedatectl set-timezone Europe/Bratislava
或者重新创建时区链接:
$ sudo unlink /etc/localtime $ sudo ln -s /usr/share/zoneinfo/Europe/Bratislava /etc/localtime
确认时区更改
$ timedatectl Local time: Tue 2015-06-06 19:57:17 CET Universal time: Tue 2015-06-06 18:57:17 UTC RTC time: Tue 2015-06-06 18:57:18 Time zone: Europe/Bratislava (CET, +0100) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no
日期:2020-07-07 20:55:13 来源:oir作者:oir