We have a TCP/IP protocol utilized to synchronize time in a network known as Network Transfer Protocol (NTP). It assists in the accurate timekeeping of network applications. This article will discuss how to set up time synchronization in Ubuntu by selecting the correct time zone and enabling the NTP service. So let’s get started!
How to view the current time zone in Ubuntu
First of all, we will check the time zone of our server. For this, we will utilize the below-given command, which will print out the current date, time, and time zone of the server:
As shown in the above output, your server’s time zone will likely be set to the “UTC” time zone. UTC is an acronym for Universal Time Zone; it refers to the time at zero degrees longitude. When your infrastructure covers many time zones, employing Universal Time Zone reduces the chance of being perplexed. However, you can utilize the “timedatectl” command to modify the time zone if you want any particular change. To do so, list out the available time zone in your Ubuntu terminal:
After executing the command, the terminal will show you a list of time zones:
You can hit “SPACE” to move down through the list and press “b” to move upwards. Note the correct time zone from the list and press “q” to exit:
How to change the current time zone in Ubuntu
Utilize the “timedatectl set-timezone” command to specify the time zone you have selected from the list. To execute the below-given command, you are required to have sudo privileges:
Again execute the “date” command to verify the changes we have made to the time zone settings:
From the output, you can see that our time zone is successfully changed from “UTC” to “EDT“, which is Eastern Daylight time:
You have learned how to check and change the time zone of your Ubuntu system until this point. Now, we will move towards the procedure of setting up time synchronization.
How to set up time synchronization in Ubuntu
Lately, the “ntpd “or Network Time Protocol daemon was in charge of most network time synchronization. This daemon links to a network of other NTP servers, which provides precise-time updates regularly. Instead of ntpd, Ubuntu’s default installation now utilizes “timesyncd“. The timesyncd connects to the same servers and functions similarly, but it is lightweight and integrated with Ubuntu’s low-level workings. By executing “timedatectl” without any parameters, you can check the status of “timesyncd”:
The output of the above-given command will display the local, Universal time, and some network statistics. “System clock synchronized” indicates that the time has been synced or not, whereas “NTP service” will show its current status on your system:
If your system’s NTP service is inactive, then you can utilize the below-given command to enable it on your Ubuntu:
Now, write out the “timedatectl” command to load the changes we made:
The output shows that the system clock is synchronized and the NTP service is active, which successfully brings us to the end of the time synchronization process!
In an Ubuntu system, time synchronization is essential because every part of the network is linked with the time when a specific event occurs, whether it is about securing, planning, managing, or debugging a process in a network. Out-of-sync time can also cause many issues on your system, such as you may not be able to execute your important jobs at the scheduled time. So, in this article, we have demonstrated how you can set up time synchronization on your Ubuntu system and how to activate the services properly.