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.
Contents
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
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
Conclusion
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.
About author
You might also like
Some Important Commands Used In Linux/Unix
This post was last updated on August 3rd, 2020 at 02:51 pmCommand-line interface(CLI) is a way that allows users to interact with computer programs through commands. A user issues commands
How To Add/Remove New User In Linux/Unix
This post was last updated on August 3rd, 2020 at 03:09 pmIn this article, we will learn to add or remove users and giving them required permissions in Linux or
How To Add/Remove A Software Repository In Linux?
This post was last updated on August 3rd, 2020 at 02:56 pmContents1 Software Repository2 Adding a repository in debian based systems3 Remove repository in Debian based systems4 Adding a repository
0 Comments
No Comments Yet!
You can be first to comment this post!