DEV Community

Ibrar Hussain
Ibrar Hussain

Posted on

NTP (Network Time Protocol) Setup for Linux (Ubuntu) Server

When you launch a new Linux server, whether it's an AWS EC2 instance or a local server, by default, the server time is not synced with the NTP server and most of the times the timezone is set to UTC.

In most cases server timing synchronizing with the NTP server is very important.

Following are the steps:

Install & Configure NTP

  • Run the following command to install the NTP
sudo apt-get install ntp
Enter fullscreen mode Exit fullscreen mode
  • Open the ntp.conf file:
sudo vi /etc/ntp.conf
Enter fullscreen mode Exit fullscreen mode
  • Check if the NTP pool entries the same as below otherwise update it:
pool 0.ubuntu.pool.ntp.org iburst
pool 1.ubuntu.pool.ntp.org iburst
pool 2.ubuntu.pool.ntp.org iburst
pool 3.ubuntu.pool.ntp.org iburst
Enter fullscreen mode Exit fullscreen mode
  • Restart the NTP service
sudo service ntp restart
Enter fullscreen mode Exit fullscreen mode
  • Check the NTP service status by running the following command:
service ntp status
Enter fullscreen mode Exit fullscreen mode

Set/Change timezone

  • Let's say you want to change the timezone to AEDT
  • You can set it by running the following command:
sudo timedatectl set-timezone Australia/ACT
Enter fullscreen mode Exit fullscreen mode
  • Restart the NTP service
sudo service ntp restart
Enter fullscreen mode Exit fullscreen mode
  • You can confirm the result by running the following command:
service ntp status
Enter fullscreen mode Exit fullscreen mode
  • and it should you the result like the following:

Alt Text

Top comments (0)