Before configuring time, you need to understand what is going on.
So how does Linux time work?
Well, when you are booting, the system gets the time from the hardware clock.
The hardware clock is the clock in the hardware of your computer.
From this hardware clock, system time is set.
And that means that system time after the boot will always synchronize with the hardware
clock.
It will follow it.
The hardware clock is potentially unreliable.
It is very common nowadays to use internet time to synchronize the time.
So it's a three-phase approach.
First, there's the hardware clock.
Hardware clock sets system time.
System time synchronizes with internet time.
But there's a catch.
If the difference between local time and internet time is more than 1,000 seconds, the NTP client
will refuse to synchronize.
So if the hardware clock gets broken and it comes up with a date like January 1, 2000,
then you need to do something manually before you can establish time synchronization.
And there's a couple of commands involved.
Hwclock is the first one.
You can use it to manage the hardware clock.
Most people use it to synchronize time because you can use hwclock minus minus sys2hc, which
is system time to hardware clock, or the opposite direction, hwclock minus minus hc2sys.
Date is what you can use to show and set time.
But nobody sets time with date anymore.
Most people use timedatectl to set time instead, as well as timezone configuration.
Let me show you how this hardware clock is working.
So hwclock is showing me what?
Showing me the time as it is right now.
So that is 20, 25, 05, 29.
20 to 22, 27, that's about 10, 30 PM.
Well, that matches what I see here on my screen.
So that is apparently all right.
Then what is date showing?
Well, date is showing the same information, more or less.
And it's adding timezone information.
So it's in CEST, Central European Standard Time.
Yeah, in Central European Standard Time, that probably makes sense.
Now, based on the output that I see here,
even with a small delay between the moment I typed hwclock and date,
they are more or less the same.
So there is no issue.
And the system seems to be ready for NTP time synchronization.
Let's continue in the next video to explore how timedatectl can be used.