by

How to sync system time with Internet time servers on Ubuntu 20.04

On computer systems, you either set the clock manually or set it to automatically sync with internet based servers. The best practice is to have it sync automatically with internet time servers unless there is a need of manual setting. Also you should make sure the clock is correctly synchronized otherwise it may cause issues and your log files and other documents may end up with wrong timestamps. Ubuntu allows you to sync your system time with internet servers both through the command line and the graphically.

In this article, we will explain how to sync your Ubuntu system time with internet time servers both through the command line and the GUI.

Note: All the commands and processes used in this tutorial have been tested on an Ubuntu 20.04 LTS (Focal Fossa).

Display Current date and time

You can view the current settings of your system clock through the timedatectl command. Open the command line Terminal application in your Ubuntu system using the Ctrl+Alt+T keyboard shortcut. Then run the following command in Terminal:

$ timedatectl

It will show the local time, universal time, time zone, and tells whether the system click synchronization is on or not. In the following output, it is showing that the synchronization is off.

timedatectl

Sync System Clock through the Command Line

By default, the Ubuntu OS uses the ntpd for synchronizing the date and time of system with internet servers. However, in this article, we will use the Chrony utility which is a light-weight and better alternative to ntpd. The Chrony utility comprises of chronyd (daemon) and the chronyc (command-line interface).

Synchronize the System Time

Chrony is not installed by default on Ubuntu systems. Therefore, we will need to first install it our system. Run the following command in Terminal to install Chrony utility on your system:

$ sudo apt install chrony

Install Chrony

The system might ask for confirmation by providing you with Y/n option. Hit Y and then hit Enter to continue, after that the Chrony utility will be installed on your system.

After installation of Chrony, again run the timedatectl command. This time you will see the synchronization has been turned on by the Chrony utility.

Check time

To check how much your system time varies from the internet server, type chronyd followed by –Q option in Terminal:

$ sudo chronyd –Q

The “System clock wrong by” line shows the offset time information.

System time offset

The above command only prints the offset; it does not synchronize the clock. To synchronize the clock as well, type chronyd followed by -q option in Terminal:

$ sudo chronyd –q

The above command will synchronize the clock and this time you will see the offset time has been reduced.

Synchronize time with chrony

You can view the currently available and trusted time servers that Chrony utility is using in order to sync the system time. Here is the command to do so:

$ chronyc sources

Chrony time sources

Sync Clock with Time Servers through the GUI

The operating system are by default set to fetch the date and time automatically form the internet time servers. You can verify it using the following method.

Open the Settings utility in your system. Right-click the Ubuntu desktop and select Settings or you can search Settings utility using the Dash menu.

Then in the Settings utility, click the Date & Time tab in the sidebar. Make sure the Automatic Date & Time slider is turned on. If it is turned off, slide it to turn it to on position. It will allow the system to automatically fetch the current date and time from available internet time servers.

Sync time using GUI settings in Ubuntu 20.04

That is all there is to it! In this article, you have learned how to sync the Ubuntu 20.04 system clock with internet time servers. I hope you liked the article.

Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

News Feed