Maintaining accurate system time is crucial for various network operations and synchronization tasks. In Ubuntu 24.04, setting up the Network Time Protocol (NTP) ensures your system clock remains synchronized with internet time servers. This guide provides a detailed walkthrough on configuring NTP on Ubuntu 24.04, ensuring your system’s timekeeping is precise and reliable.
In this tutorial you will learn:
- How to install the NTP service on Ubuntu 24.04
- Steps to configure NTP servers in the NTP configuration file
- How to restart and check the status of the NTP service
- Verifying the synchronization of your system clock with NTP servers
- Additional configurations and tips for NTP

Installation and Configuration Steps
Follow these steps to install, configure, and verify the NTP service on your Ubuntu 24.04 system.
- Install the NTP Service: Start by updating your package lists to ensure you have the latest version of the repositories.$ sudo apt updateThen, install the NTP package using the following command:$ sudo apt install ntpThis command installs the NTP service on your Ubuntu system, making it ready for configuration.
- Configure NTP Servers: Configuring your NTP servers is a critical step. Open the NTP configuration file in a text editor of your choice. Here, nano is used for simplicity.$ sudo nano /etc/ntp.confIn the configuration file, add or modify the server lines to specify your preferred NTP servers. For example:server 0.ubuntu.pool.ntp.org server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org These servers are part of the Ubuntu pool, but you can choose other public NTP servers closer to your geographic location.
- Restart NTP Service: After configuring your servers, restart the NTP service to apply the changes.$ sudo systemctl restart ntpThis command ensures that the NTP service starts using the new configuration.
- Check NTP Service Status: To confirm that NTP is functioning correctly, use the systemctl command.$ sudo systemctl status ntphttps://201394bd3acb09e3f9ecc50465b45eb6.safeframe.googlesyndication.com/safeframe/1-0-40/html/container.html
This output provides the current status of the NTP service, indicating whether it’s active and running.Check NTP Service Status
- Verify NTP Synchronization: Checking synchronization status helps ensure that your system clock is accurate.$ ntpq -pThe output from this command shows the list of NTP servers you’re synchronized with and various related statistics.
Verify NTP Synchronization
- Enable NTP to Run After Restart: To ensure that the NTP service automatically starts upon system reboot, enable it using the systemctl command.$ sudo systemctl enable ntpThis command configures the NTP service to start automatically whenever your system boots up, maintaining consistent time synchronization.
- Optional Configuration: For advanced users, additional configuration options are available in the NTP configuration file. You can set various parameters like drift file, access restrictions, and more.
Open the configuration file again:$ sudo nano /etc/ntp.confHere, you can fine-tune your NTP settings. For example, to restrict which hosts can query your NTP server, add lines like:restrict example-host.com nomodify notrapThese settings are optional but can be useful for managing larger networks or for specific use cases.
Conclusion
Setting up NTP on Ubuntu 24.04 is a simple yet vital task for maintaining accurate system time. By following these steps, you can ensure that your system is correctly synchronized with global time servers, which is essential for network operations, security, and time-sensitive tasks. Regular monitoring and occasional reconfiguration might be necessary to maintain optimal performance and accuracy.