Linux 同步网络时间、设置时区

设置时区

使用命令:dpkg-reconfigure tzdata,选择需要的时区,这里选择亚洲-上海。

image-20210216125415401
image-20210216125415401

image-20210216125458321
image-20210216125458321

同步时间

安装ntpdate

sudo apt install ntpdate
# 同步网络时间,这里是中国的公共NTP服务器
sudo ntpdate cn.pool.ntp.org
# 将系统时间写入硬件时间
sudo hwclock --systohc