ubuntu系统当前的时间和时区
ubuntu系统当前的时间和时区
查看当前时间
date
查看当前时区
timedatectl
修改系统时间
sudo date -s "YYYY-MM-DD HH:MM:SS"
使用 NTP(网络时间协议)同步时间
NTP 可以让你的系统时间与网络上的时间服务器同步,确保时间的准确性。
- 安装 NTP 服务:
sudo apt-get update
sudo apt-get install ntp
- 启动并设置 NTP 服务开机自启:
sudo systemctl start ntp
sudo systemctl enable ntp
- 查看 NTP 服务状态:
sudo systemctl status ntp
修改系统时区
- 列出所有可用的时区:
timedatectl list-timezones
- 设置新的时区:
sudo timedatectl set-timezone "时区名称"
sudo timedatectl set-timezone Asia/Shanghai