ubuntu安装ntp服务
时间: 2023-11-11 15:00:40 浏览: 44
好的,安装ntp服务可以按照以下步骤进行:
1. 打开终端,输入以下命令安装ntp服务:
```
sudo apt-get update
sudo apt-get install ntp
```
2. 安装完成后,可以通过以下命令检查ntp服务是否已经启动:
```
sudo systemctl status ntp
```
如果ntp服务已经启动,则会显示类似于以下内容:
```
● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-10 14:22:22 CST; 1h 5min ago
Docs: man:ntpd(8)
Main PID: 1234 (ntpd)
Tasks: 2 (limit: 4915)
Memory: 2.3M
CGroup: /system.slice/ntp.service
└─1234 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 121:130
Aug 10 14:22:22 ubuntu systemd[1]: Starting Network Time Service...
Aug 10 14:22:22 ubuntu ntpd[1234]: ntpd 4.2.8p12@1.3728-o (1)
Aug 10 14:22:22 ubuntu ntpd[1234]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 121:130
Aug 10 14:22:22 ubuntu ntpd[1234]: proto: precision = 0.100 usec (-23)
Aug 10 14:22:22 ubuntu ntpd[1234]: leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): good hash signature
Aug 10 14:22:22 ubuntu ntpd[1234]: leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): loaded, expire=2022-06-01T00:00:00Z last=2017-01-01T00:00:00Z ofs=37
Aug 10 14:22:22 ubuntu ntpd[1234]: Listen and drop on 0 v6wildcard [::]:123
Aug 10 14:22:22 ubuntu ntpd[1234]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Aug 10 14:22:22 ubuntu ntpd[1234]: Listen normally on 2 lo 127.0.0.1:123
Aug 10 14:22:22 ubuntu ntpd[1234]: Listen normally on 3 enp0s3 192.168.1.101:123
Aug 10 14:22:22 ubuntu ntpd[1234]: Listening on routing socket on fd #22 for interface updates
Aug 10 14:22:22 ubuntu systemd[1]: Started Network Time Service.
```
3. 如果ntp服务没有启动,可以使用以下命令手动启动ntp服务:
```
sudo systemctl start ntp
```