? How To Change Timezone and NTP Synchronization on Ubuntu 16.04
How To Change Timezone and NTP Synchronization on Ubuntu 16.04
Setting up the correct timezone and date in Linux is very important as most of things depends on it. The server and system clock needs to be on time which does not matter if you are using Linux on your personal computer or you have a Linux server in production. NTP (Network Time Protocol) enables the synchronization of computer clocks distributed across the network by ensuring accurate local timekeeping with reference to some particular time on the Internet. NTP communicates between clients and servers using the User Datagram Protocol on port No.123. NTP uses a systematic, hierarchical level of clock sources for its reference. Each level is called a stratum and has a layer number that usually begins with zero. The stratum level serves as an indicator of the distance from the reference clock in order to avoid cyclic dependenc in the hierarchy. However, the stratum does not represent the quality or reliability of time.
The NTP software package includes a background program known as a daemon or service, which synchronizes the computer’s clock to a particular reference time such as radio clock or a certain device connected to a network. Now let’s see how we going setup Timezone and NTP Synchronization on Ubuntu 16.04.
Let’s start with setting up the correct timezone on your Ubuntu server. Run the below command with root user credentials and you will be presented with a menu system that allows you to select the geographic region of your server. Select the geographic area in which you live and press ‘OK’ to continue.
# dpkg-reconfigure tzdata
Then select the city or region corresponding to your time zone as shown.
Press the ‘OK’ key and your system will be updated to use the selected timezone, and you will get the below output showing your default zone and date.
root@ubuntu-16:~# dpkg-reconfigure tzdata
Current default time zone: ‘Europe/London’
Local time is now: Tue May 24 21:00:31 BST 2016.
Universal Time is now: Tue May 24 20:00:31 UTC 2016.
You can also configure your Timezone on Ubuntu server by using the following command. To check the list of all available timezones, run below command.
# timedatectl list-timezones
Then select your desired timezone from the listed output and run below command to configure it on your system.
# timedatectl set-timezone Europe/London
Now run you can verify that the timezone has been set properly by using the ‘timedatectl’ command in your command line terminal, where you will get the information about your timezone settings as shown.
Setup NTP Synchronization:
To setup NTP synchronization, we will use a service called ntp, which we can be installed from Ubuntu’s default repositories by using below command.
# apt-get install ntp
That’s it, you have successfully installed NTP package to set up NTP synchronization on Ubuntu 16.04. The daemon will start automatically on each boot and will continuously adjust the system time to be in-line with the global NTP servers throughout the day.
Configure NTP Servers:
To configure and change the default NTP servers, open up the below configuration file and find the section within the configuration that lists the NTP Pool Project servers as shown.
# vim /etc/ntp.conf
These lines refers to a set of hourly-changing random servers that provide your server with the correct time, which are located all around the world. You can get their list by using below command.
# ntpq -p
When you made any changes to the configuration, make sure to restart ntp service with below command.
# service ntp restart
That’s it. In this article you have learned about Timezone and NTP synchronization on Ubuntu 16.04. NTP can be easily deployed on servers hosting different services which requires less resource overhead and minimal bandwidth requirements. NTP can handle hundreds of clients at a time with minimum CPU usage. Thank you for reading this article and I hope you find it much helpful. Let’s share your thoughts on it.