Networking

How To: Enable NTP In Linux

Time is very important to the Linux operating system so keeping accurate time is important, which is why we want to enable NTP in Linux. This won’t be a major article and it should be simple enough to follow along. It’s pretty easy to enable NTP in Linux.

If you don’t know, NTP stands for Network Time Protocol. This allows your computer to connect to a networked device that tells your computer the accurate time and then syncs your computer’s clock with that accurate time.

This networked time server is usually just on the public web, but you could do things like run your own NTP server with a GPS device. (GPS uses really, really, really accurate time. In fact, that really accurate time is how GPS works.) Your company may even run its own NTP servers, but there are plenty of public servers available.

While we’re on the subject, your Linux computer keeps time in a very funny fashion. It counts the seconds since the epoch. The “UNIX Epoch” is an arbitrary date and time. Specifically, it counts the seconds since January 1st, 1970 at 00:00:00 UTC. I’ll write an article on the subject at some point. It is also sometimes referred to as “POSIX Time”. In the meantime, you can always look it up at your favorite search engine. 

Time is very important to Linux. After all, the kernel is a task scheduler. It’s also important for accurate record keeping, among other things. It’s also not difficult to enable NTP in Linux.

NOTE: This article assumes you’re using systemd, as most mainstream distros do. If this isn’t true, this article isn’t for you.

Enable NTP In Linux:

Yes, this is another article that requires an open terminal. You can usually just press CTRL + ALT + T to open your default terminal. If that’s not true, fix the keybindings!

If you’re a desktop user, you can probably skip this article. If you’re a desktop Linux user, odds are good that your distro came preconfigured to sync the time already. Let’s go ahead and verify that with this command:

timedatectl

What you’re looking for is these lines:

System clock synchronized: yes
              NTP service: active

You’re especially interested in the last line. If that line says that the NTP service is active, you can ignore this article and read one of the prior articles on the timedatectl command:

How To: Find Your Timezone In The Terminal
How To: Change The Timezone

If the NTP service is not active, you can start the service with this command:

sudo timedatectl set-ntp on

That’s all you need to do to enable NTP in Linux.

If you want to disable NTP, that’s just as easy. That command looks like this:

​sudo timedatectl set-ntp off

Next, you can run this command to confirm that you’ve enabled NTP:

timedatectl

That should output information that says the NTP service is active. It may not say that the clock has synchronized as that may take some time before the scheduled task runs and syncs your time with a dedicated time-keeping server.

If you want to muck about with the settings, they’re viewed here:

cat /etc/systemd/timesyncd.conf

You’d edit that file with Nano, or some other terminal text editor. Before doing so, you should first read the man page, with this command:

man timesyncd.conf

There you go! You can enable NTP in Linux!

Closure:

It seems that I’ve developed a few different styles for my article writing. Longer articles get treated differently, as in they’re formatted differently. The shorter articles have been formatted like this for quite a while. I think that’s a comfortable mix, though it is (as always) subject to change. As I learn and grow, so too may the formatting.

Anyhow, this seemed like a fun article to write. I doubt it’ll be all that popular. It’s unlikely to rank all that well in the search engines. Still, it’ll be information that’s on the site, and the more information I have the better I think I’ll be doing.

It’s not always about the traffic. Indeed, it was never really about the traffic. The traffic is secondary. My primary objective is to share information. Today’s article covered how to enable NTP in Linux. Further, it is limited to just those who use systemd.

Most of my readers will have no use for this information. But, there will be someone – and maybe only that one someone – who will find this information and need it to enable NTP on their Linux device. Good. To that reader and my regulars, I say thanks for visiting.

Now my usual blurb at the bottom of every article…

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Is Your Storage Drive An SSD Or An HDD?

Today's article aims to answer a simple question, simply is your storage drive an SSD…

13 hours ago

Monitor System Resources With “Resources”

Today is one of those days when I'd like to introduce you to new software…

3 days ago

Short: The Halt Command

Today's article is intentionally short because we're simply going to learn about the basics of…

5 days ago

Installing Flatpaks In Linux

Today we're going to have a pretty easy article where you'll learn about installing Flatpaks…

7 days ago

A Quick Look At The Shutdown Command

This is going to be just a quick article about a command many of you…

1 week ago

Setting Up Coding Environments on Linux for Educational Use

With so many strong attributes, such as robustness and flexibility, Linux stands as a powerful…

2 weeks ago