Configure an NTP Client on Linux
Learn to install and configure the legacy ntpd NTP client on Debian or Ubuntu, choose time servers, restart the service, and verify synchronization with ntpq.
Network Time Protocol (NTP) synchronizes a computer's system clock with authoritative or upstream time servers. An NTP client requests time from remote servers and disciplines its own clock; it does not provide time to other machines.
Accurate system time is important for ordered log entries, scheduled jobs, authentication systems, TLS certificate validation, monitoring alerts, backups, and distributed applications that exchange timestamps.
NTP Client Configuration Workflow
Install the NTP Daemon
The ntp package contains the legacy NTP daemon, commonly called ntpd, along with related utilities such as ntpq. Installing packages and managing services requires administrative privileges, normally provided through sudo.
sudo apt-get update
sudo apt-get install ntp
You can use the shorter modern form on Debian or Ubuntu systems:
sudo apt update
sudo apt install ntp
Before installing or starting ntpd, check whether another time service is already active. For example, chronyd and systemd-timesyncd may already be managing the clock. Two daemons can compete for control of time synchronization or required system resources, so stop or disable the unneeded service according to your operating policy before starting ntpd.
sudo systemctl status chrony
sudo systemctl status systemd-timesyncd
sudo systemctl status ntp
Edit /etc/ntp.conf
The primary configuration file for the legacy daemon is /etc/ntp.conf. Its pool and server directives identify upstream time sources.
Make a backup before editing:
sudo cp /etc/ntp.conf /etc/ntp.conf.backup
Open the file with a terminal text editor:
sudo nano /etc/ntp.conf
In nano, save with Ctrl+O, press Enter to confirm the filename, and exit with Ctrl+X. Preserve valid existing settings unless you have a reason to change them.
Choose Upstream NTP Servers
Use the distribution pool
A distribution commonly supplies default pool entries. An NTP pool is a DNS-based group of time servers. DNS can return different members of the group, giving the client several possible sources instead of depending on one fixed host.
pool 0.ubuntu.pool.ntp.org iburst
pool 1.ubuntu.pool.ntp.org iburst
pool 2.ubuntu.pool.ntp.org iburst
pool 3.ubuntu.pool.ntp.org iburst
The iburst option requests a short burst of initial queries so a newly started client can obtain useful measurements more quickly. Retaining the distribution's pool entries is suitable when they are allowed by your network and organization.
Use approved or internal servers
Organizations may require local, regional, or approved NTP sources. Replace or supplement pool entries with several reliable servers:
server ntp1.example.internal iburst
server ntp2.example.internal iburst
server ntp3.example.internal iburst
The names ending in .example.internal are placeholders. Substitute hostnames that your organization actually provides. Using multiple sources lets ntpd compare measurements and continue operating if one source fails.
Conceptually, server names a particular NTP source, while pool names a DNS-managed group from which several potential sources can be discovered. Hostnames require working DNS resolution. All sources also require network connectivity to NTP over UDP port 123.
Apply Configuration Changes
After saving /etc/ntp.conf, apply the changes. A reload asks the running service to reread its configuration without a full daemon restart:
sudo service ntp reload
If reload is unavailable or does not resolve the problem, restart the service. A restart stops and starts the daemon:
sudo service ntp restart
On a system using systemd, the equivalent restart command is:
sudo systemctl restart ntp
Check the service state if startup fails or if you want confirmation that the daemon is running:
sudo systemctl status ntp
Service names and management commands can vary between distributions and package versions. Use the service name reported by the installed package.
Verify Peers and Synchronization
Run ntpq -p to query the local daemon and display its configured upstream peers:
ntpq -p
A typical result resembles this terminal-style output:
remote refid st t when poll reach delay offset jitter
=============================================================================
*ntp1.example.net .GPS. 2 u 32 64 377 12.4 -0.31 0.45
+ntp2.example.net .PPS. 2 u 28 64 377 15.1 0.18 0.62
-ntp3.example.net .ATOM. 3 u 30 64 377 21.7 1.24 1.10
The character at the beginning of a peer row is a selection marker. An asterisk (*) identifies the source currently selected for synchronization. A plus sign (+) indicates a usable candidate, while a minus sign (-) indicates a source that is reachable but less suitable than the selected candidates. Exact markers can vary as measurements change.
Key ntpq -p fields
A newly started client may need several polling intervals before it has enough samples to select a source and report stable values. Do not treat the absence of an asterisk immediately after startup as conclusive failure.
Time Synchronization Service Considerations
Troubleshooting
No reachable peers or a reach value of zero
- Check the
serverandpoollines in/etc/ntp.conf. - Verify DNS resolution when hostnames are configured.
- Confirm that the machine has a route to the upstream servers.
- Check local and network firewall rules. NTP uses UDP port 123, and outbound filtering can block synchronization.
- Restart the service after correcting the configuration.
The service fails to start
- Inspect the service status and system logs for the specific error.
- Check whether
chronydorsystemd-timesyncdis active. - Review recent edits for configuration syntax errors.
- Confirm the installed package and service name if commands behave differently on the host.
Peers are listed but no source is selected
- Allow additional polling intervals so the daemon can collect samples.
- Review reachability, offset, jitter, and selection markers.
- Use multiple reliable sources rather than one server.
- Check whether the local clock is far from correct or whether the configured sources disagree substantially.
Time remains inaccurate
- Confirm that the service was reloaded or restarted after editing the file.
- Run
ntpq -pand verify that a reachable source is selected. - Identify whether another time service is actually controlling the clock.
- Be cautious when making large clock corrections: abrupt changes can affect scheduled tasks, log ordering, authentication, TLS validation, and other time-sensitive applications.
Exam-Relevant Notes
- NTP means Network Time Protocol.
- An NTP client obtains time from upstream servers and disciplines its local clock; it is not automatically an NTP server for other machines.
ntpdis the legacy daemon,ntpis the Debian or Ubuntu package, and/etc/ntp.confis its primary configuration file.poolrefers to a DNS-based group of possible time servers;serverrefers to a specified time source.ntpq -pdisplays peers. The leading*marks the current synchronization source.- NTP communication uses UDP port 123.
- Run only one primary clock-synchronization implementation, such as
ntpd,chronyd, orsystemd-timesyncd.
For related Linux fundamentals, see Linux, Show the Full Path of Shell Commands, and Bourne Again Shell Bash.