在 CentOS 系统中,您可以使用 timedatectl 命令来查询和设置系统时区。以下是具体步骤:
timedatectl status | grep "Time zone"
列出所有可用的时区:
timedatectl list-timezones
这将显示一个包含所有可用时区的列表。
设置时区:
假设您想将时区设置为 Asia/Shanghai,可以使用以下命令:
sudo timedatectl set-timezone Asia/Shanghai
验证时区设置: 再次使用以下命令确认时区已正确设置:
timedatectl status | grep "Time zone"
查看当前系统时间:
date
同步系统时间: CentOS 默认使用 NTP 服务同步时间。您可以手动同步时间:
sudo ntpdate pool.ntp.org
或者重启 NTP 服务:
sudo systemctl restart chronyd
timedatectl 工具。大多数现代 CentOS 版本默认安装了这个工具。tzselect 命令来设置时区。希望这些信息对您有所帮助!如果有其他问题,请随时提问。