Instiq
Chapter 4 · Essential System Services·v1.0.0·Updated 7/6/2026·~11 min

What's changed: Initial version (topic 1.09, subtopics 1.09.1–1.09.3)

4.1Managing System Time

Key points

Learn to keep and synchronize system time: date and the hardware clock (hwclock), time zone configuration (/usr/share/zoneinfo/, /etc/localtime, /etc/timezone, TZ, tzselect, timedatectl), and NTP synchronization (ntpd, ntpdate, ntpq, chronyd, chronyc, pool.ntp.org).

Correlating logs, validating certificates, authentication—accurate time underpins everything. Linux keeps two clocks (the OS-maintained system clock and the motherboard's hardware clock), and the standard practice aligns them to internet time sources via NTP.

4.1.1The two clocks and time zones

  • date shows/sets the system clock (date, formatted date +%Y-%m-%d). hwclock reads/syncs the hardware clock (hwclock --systohc writes system→hardware; --hctosys the reverse).
  • Time zones live as files under /usr/share/zoneinfo/; configuration means symlinking /etc/localtime to one (Debian family also records the name in /etc/timezone).
  • Set with timedatectl (the systemd-era integrated tool: timedatectl set-timezone Asia/Tokyo, plus status), pick interactively with tzselect, or switch temporarily via the TZ variable (TZ=UTC date).

4.1.2Synchronizing with NTP

  • NTP synchronizes with time sources over the network (UDP/123). The standard public source is pool.ntp.org—a worldwide server pool served via DNS.
  • Traditional: ntpd (daemon, gradual correction; config in ntp.conf), ntpdate (one-shot immediate set; deprecated), ntpq (ntpq -p shows peers and sync state).
  • Current mainstream: chronyd (the successor daemon, robust on flaky links and VMs; config in chrony.conf) with chronyc (chronyc sources lists references).
Exam point

Staples: hwclock --systohc writes system→hardware (direction questions), set zones with timedatectl set-timezone (implemented as the /etc/localtime link), gradual daemon correction = ntpd/chronyd vs one-shot = ntpdate, check sync with ntpq -p / chronyc sources. NTP's UDP/123 also reappears among the 1.07 port questions.

Frame the two clocks operationally. At power-on the OS reads the battery-backed hardware clock to initialize the system clock; thereafter the OS ticks the system clock, and NTP daemons correct that side. Hence the tradition of writing back with hwclock --systohc before shutdown or after large corrections (automated under systemd). Why do ntpd/chronyd correct gradually (slew)? Because time going backwards reorders logs, skips or duplicates cron runs, and can corrupt databases. That is why one-shot tools like ntpdate are dangerous on live servers—the exam-correct instinct is "running systems get gradual daemon correction". VMs drift easily due to host scheduling, a context where chrony is preferred—worth remembering.

GoalCommandKey point
Show/set system timedate / timedatectltimedatectl integrates it all
Write system→hardwarehwclock --systohc--hctosys is the reverse
Change time zonetimedatectl set-timezoneImplemented via /etc/localtime
Check sync statentpq -p / chronyc sourcesShows peers and reachability
Warning

Trap: "hwclock --systohc applies the hardware clock to the system" is wrong (that is --hctosys; parse systohc = system to hardware clock). And "fix drift on a live production server instantly with ntpdate" is wrong—sudden jumps (especially backwards) cause incidents; gradual daemon correction is the right answer.

System vs hardware clocks, time zones, and NTP daemons.
Live systems slew gradually

4.1.3Section summary

  • System clock (date/timedatectl) ⇔ hardware clock (hwclock; mind --systohc's direction); zones = zoneinfo → /etc/localtime link
  • Sync via resident ntpd/chronyd (gradual); source = pool.ntp.org; verify with ntpq -p / chronyc sources

Sign in to track progress — Log in.

Quick check

(just a quick review)

Q1. You want to write the NTP-corrected system time into the hardware clock. Which command?

Q2. You must permanently set a systemd server's time zone to Asia/Tokyo. Which command?

Q3. A live production database server has drifted by a few minutes. What is the most appropriate fix?

Check your understandingPractice questions for Chapter 4: Essential System Services

Keep track of your progress

The full study guide is free to read. Sign up free to practice with the question bank, track what you have read, review your mistakes, and highlight passages.