Though it might seem like something that should be automatically taken care of, time settings on Linux can often get messed up or configured incorrectly. Since time settings on Linux can be confusing to fix for the average user, we’re going to break down and explain how to set up network time sync on Linux.
In addition to setting up NTP, we’ll also explain how to fix the annoying time error when dual-booting Linux and Windows.
Configure Network Time Protocol
Syncing the software clock on your Linux PC with time servers is the most common way to get the precise time. On most Linux distributions, this is done automatically. However, not every Linux distribution uses NTPd. Furthermore, ones that do may mess it up or configure it incorrectly. To remedy this, we’re going to explain how easy it is to manually configure the Network Time Protocol daemon under Linux.
Get started by opening up a terminal and installing NTP, if your PC doesn’t have it installed. There’s a good chance you already have it, but to be safe, here are the commands to get it for most modern Linux distributions.
sudo apt install ntp
sudo apt-get install ntp
sudo pacman -S ntp
sudo dnf install ntp
sudo zypper install ntp
With the software installed, you’ll next need to connect to an NTP server. By default, most Linux distributions have their own NTP servers configured in the /etc/ntp.conf file. However, if you feel these servers are unreliable, you can change it to a more reliable server (like the official Google NTP server).
if (navigator.appVersion.indexOf(“Mac”)!=-1) document.write(”);
RECOMMENDED FOR YOU
To add the Google NTP server, edit the ntp.conf file.
sudo nano /etc/ntp.conf
Erase all entries, if you wish and replace them with these (though we don’t recommend it). For best results, paste the Google NTP entries at the very top.
Note: it’s important that iburst is at the end of each of the new entries. The iburst option will send a “burst” of packets to the servers only when you face connection issues with the time server.
server time.google.com iburst server time2.google.com iburst server time3.google.com iburst
When done, save the configuration file in Nano with Ctrl + O. Exit the editor with Ctrl + X.
NTP can automatically sync time from servers but first, it needs to know the time zone. Usually, during initial setup, your Linux operating system will ask the timezone and set it. If something went wrong during install, this will need to be corrected manually using tzselect.
Open a terminal and run the timezone tool:
Running the Tzselect tool will walk you through configuring the right time zone. Once done, you’ll be able to start NTPd.
All of the connections to time servers work. The next step in the process is to use the Systemd init system to load NTP at boot. Do understand that if your Linux operating system doesn’t use systemd like most modern, mainstream ones, you’ll need to find the alternative to these commands.
First, start up NTPd:
sudo systemctl start ntpd.service
Then, enable it at boot with systemctl enable.
sudo systemctl enable ntpd.service
Running the above commands should instantly configure the time, as the UTC time on your BIOS is now correct (thanks to Tzselect).
Use Local Time
There are other ways to set time on Linux, aside from NTP. The most popular alternative to that method is “local time”. Local time tells Linux to keep time, but not to sync with anything. Essentially, it will keep the time self-contained and not interfere with anything. It’s less reliable, but it works. Question is, why would you want to do this?
The main reason one would go with local time over something like NTP is the fact that dual booting messes with your time. If you’ve ever loaded up Linux, then rebooted into Windows 10, you’ll notice the time breaks. This is because both operating systems have a time sync service, and fight with each other. The main way to fix this is to disable time syncing in Linux.
Note: keep in mind that even though you’ve set Linux to use local time, Windows may still face issues. Make sure to check the Windows time settings to make sure no further conflicts with the two operating systems arise.
Running timedatectl should fix it:
sudo timedatectl set-local-rtc 1
After reverting to local time, you may need to reboot your PC. After logging back in, everything should be using local time.
Want to turn local time back off? If so, you’ll need to re-run the timedatectl command. Try the command below.
sudo timedatectl set-local-rtc 0
Like before, restart your Linux PC for good measure. At the next login, local time shouldn’t be in use.