文章目录
Linux系统时区设置与NTP时间同步
1. 修改系统时区
步骤1:查看当前时区
运行以下命令来查看当前系统时区:
timedatectl
步骤2:设置新时区
假设想将系统时区设置为"Asia/Shanghai",运行以下命令:
sudo timedatectl set-timezone Asia/Shanghai
2. 使用NTP进行时间同步
步骤1:安装NTP客户端
sudo apt-get install ntp # 对于Debian/Ubuntu
sudo yum install ntp # 对于CentOS/RHEL
步骤2:配置NTP服务器
编辑NTP配置文件,通常位于/etc/ntp.conf
。
server pool.ntp.org
步骤3:启动NTP服务
启动NTP服务并设置它在系统启动时自动启动:
sudo systemctl start ntp
sudo systemctl enable ntp
步骤4:检查同步状态
ntpq -p