Home › Linux command line: first steps › Step 3

Lesson 3: Linux time - RTC versus the system clock

Step 3 of 5 in Linux command line: first steps · video 7:30

Can't see the video? Watch it on YouTube.

What you will learn

About this lesson

How Linux keeps time and how to manage it with timedatectl. A computer has two clocks: the real-time clock (RTC), a hardware clock that keeps running while the machine is off, and the system clock, maintained by the kernel, which takes its starting value from the RTC at boot and then runs independently. System time is held in UTC and converted to local time, including daylight saving time, for display. The RTC can be kept in UTC or local time, and UTC is the recommended choice. The lesson uses timedatectl, part of systemd, to show local and universal time, the time zone and the NTP status; to set the time and date with set-time; to list time zones and filter them with grep; to change the zone with set-timezone; to keep the RTC in local time with set-local-rtc; and to turn automatic synchronisation on or off with set-ntp. It also shows that manual set-time fails while synchronisation is enabled.

Good to know: Red Hat Enterprise Linux 8 and later use chronyd for NTP; ntpd is no longer shipped.

Check yourself

Answer in your head first, then open each question to see the answer.

1. Which clock keeps counting while the server is powered off, and how does the other clock get its time at boot?

The real-time clock (RTC), a hardware clock independent of the operating system. The system clock is kept by the kernel; it is initialised from the RTC at boot and then runs on its own.

2. What happens if you run timedatectl set-time 14:30:00 on a machine that synchronises with NTP?

The command fails with an error saying automatic time synchronisation is enabled, because a manual change would fight the NTP service. Turn it off first with timedatectl set-ntp false if you really need to set the time by hand.

3. A server in Berlin shows UTC as its local time. How do you find the right zone name and switch to it?

List the zones and filter them, timedatectl list-timezones | grep Europe, then as root run timedatectl set-timezone Europe/Berlin. The zone must be one of the names the list prints.

4. Should the hardware clock be kept in UTC or local time, and which timedatectl option controls it?

UTC is recommended, because it avoids jumps at daylight saving changes. timedatectl set-local-rtc 0 keeps the RTC in UTC, while set-local-rtc 1 would switch it to local time.

Go deeper

This lesson comes from the course below - with the full set of lessons, demonstrations and practice.

Administration of Red Hat Enterprise Linux

4.5★ · 10,209 students on Udemy

See the course on Udemy
← Lesson 2: Essential Linux commands every admin needsNext: Lesson 4: date and hwclock - setting the hardware clock →

Video lesson by Vitalii Shumylo. The summary and the questions on this page were written from the lesson with AI help and checked against its transcript.