Time synchronization is essential for ensuring the reliability, security, and functionality of Debian and other Unix-like systems. The Network Time Protocol (NTP) is an essential element for time sync that synchronizes the clocks of client computers with a time server.
This article explains how to set up time synchronization on Debian using NTP and an alternative.
- Debian system (this tutorial uses Debian 11).
- Non-root sudo access.
Note: Learn how to create a user with sudo privileges on Debian.
Setting up Time Sync on Debian
Correct time setting is essential for the proper functioning of modern software. Poor time synchronization across systems leads to various issues, from simple errors to severe data corruption. The following sections explain how to set up time synchronization on Debian.
Step 1: Check Time on Debian
Check the time on the server with the date command:
The output shows the current time as well as the current date. The current time in the output is usually in Coordinated Universal Time (UTC). UTC is the time at zero degrees longitude and is accepted as a universal timezone.
Step 2: Set up Timezone
date command prints the UTC zone by default. However, users sometimes need to change the timezone on Debian, which is done with the
timedatectl command. Take the following steps to change the timezone on Debian:
1. List the available timezones on Debian:
The command prints a list of all the available timezones.
2. Navigate the output with the Spacebar and b key.
3. Choose the timezone. For example, US/Eastern.
4. Press q to exit the list.
5. Change the timezone with the following command:
sudo timedatectl set-timezone <timezone>
For example, to change the timezone to US/Eastern run:
sudo timedatectl set-timezone US/Eastern
The command shows no output
6. Verify the change with
The output shows the EDT time, the abbreviation for Eastern Daylight Time in US and Canada.
Note: Check out our tutorial on how to set or change the timezone, date, or time on Ubuntu.
Step 3: Check The Status of ntpd
Debian runs the standard Network Time Protocol daemon (
ntpd) to sync the system time with external time servers. While NTP is the protocol for synchronizing time,
ntpd is the program which implements the NTP protocol.
ntpd is running, execute the systemctl command:
sudo systemctl status ntp
The output shows the
ntpd service is active. Therefore,
ntpd is running and in sync with a time server.
ntpq command provides additional info about the
ntpq command is an
ntpd query tool. The
-p argument specifies info about the NTP servers to which
ntpd currently connects to.
Switching from ntpd to timesyncd
Timesyncd is a lightweight
ntpd alternative, which is simpler to configure, more efficient, and more secure. Furthermore,
timesyncd also integrates better with
systemd. This feature makes it easy to manage using the
timesyncd cannot be used as a time server, and it is less sophisticated in keeping the system time in sync. These features make the program a less suitable choice for systems in need of accuracy and reliability. Complex real-time distributed systems generally work better with
Still, users who choose
timesyncd need to remove
ntpd first. Follow the steps:
sudo apt purge ntp
2. If the
timesyncd is not on the system, run the following to install it:
sudo apt install systemd-timesyncd
2. Start the
sudo systemctl start systemd-timesyncd
The command has no output.
3. Check the status:
sudo systemctl status systemd-timesyncd
The output confirms
timesyncd is running. To display the current time and date, run:
The output prints info such as:
- Local time.
- Universal time.
- System real-time clock (RTC) time.
- Confirmation the system clock is synchronized.
ntpd instead of timesyncd does not change the process of checking the date and time, or timezones, or changing timezones. The commands are the same, regardless of which NTP daemon is used.
After reading this text, you now know how to set up time synchronization on Debian with