How to Sync System Time By Using timedatectl Command On Ubuntu?

The system clocks are not perfect they are prone to drift that means over the time it starts lagging from the actual time. There are many network services that require the correct time on a local system.

So the Network Time Protocol (NTP) provides a way to maintain the accuracy of a system clock. NTP is an internet protocol that is used to synchronize time across the multiple servers.

Ubuntu by default uses timedatectl/timesyncd to synchronize system time with NTP servers optionally anyone can choose the chrony to serve the purpose.

Check the current status of time configuration

You can check the current status of time configuration by using timedatectl command –

timedatectl status

This will display information such as local time, universal time, the system clock is synchronized or not, NTP service is active or not, etc.

In Ubuntu by default NTP service is active and the system clock is synchronized, see the image below.

Enabling NTP service

If NTP service is not active in your system then use the following command –

timedatectl set-ntp true

Also if you want you can disable the NTP service by using –

timedatectl set-ntp false
[alert color=”yellow”]Note: NTP daemon communicates with the NTP server or peers on the network using UDP packets on port number 123. So firewall in your system should be configured to allow the UDP packets on port 123.[/alert]

Configure NTP servers

The server from which timedatectl and timesyncd fetch time is specified in the /etc/systemd/timesyncd.conf and the additional configuration files are stored in /etc/systemd/timesynd.conf.d/

You can open the timesyncd.conf using a text editor such as nano

nano /etc/systemd/timesyncd.conf

The configuration file will look something like this –

In the “[Time]” section of this file –

NTP= Contains a list of NTP servers separated by space. When the empty string is assigned the list of NTP server is reset

FallbackNTP= This contains a space-separated list of NTP servers to be used as the fallback NTP servers. This setting is only used when there is no other NTP server information is known.

You can see full details of this section in the man page of timesyncd.conf file –

man timesyncd.conf


By reading this article you can now synchronize your system time with NTP servers. Now if you have a query you can write to us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.