Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท System Information

Linux timedatectl command

Reference for timedatectl: show and set the system clock, time zone and NTP sync on systemd machines, and read the same facts from files in a sandbox.

timedatectl is the systemd tool for inspecting and changing the system clock, the time zone and time synchronization (NTP). One command shows the local time, UTC, the configured zone, whether the clock is synchronized and whether the hardware clock is kept in UTC.

It talks to the systemd-timedated service, so it only works on a machine running systemd. The examples that run here read the same information from plain files and date, which also works on systems without systemd.

Terminal
timedatectl [status | show | set-time TIME | set-timezone ZONE | list-timezones | set-ntp BOOL]

Try it

Bash Reading time settings without systemd

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash The TZ variable overrides the zone per command

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
timedatectl [OPTIONS] [COMMAND]
Command Description
status Default. Local time, UTC, RTC time, zone, System clock synchronized, NTP service, RTC in local TZ.
show The same facts as KEY=VALUE lines for scripts; add -p Timezone --value for one value.
set-time "YYYY-MM-DD HH:MM:SS" Set the clock manually (turn NTP off first). Needs root.
set-timezone ZONE Set the zone, for example Europe/Paris. Needs root.
list-timezones One zone name per line (pipe to grep).
set-ntp BOOL Enable or disable network time sync.
set-local-rtc BOOL Keep the hardware clock in local time (only for dual-boot with Windows).

Errors: Failed to connect to bus or System has not been booted with systemd in containers; Access denied for set commands without root.

Usage notes

  • Zones, not offsets. Set a named zone (America/Chicago), not a fixed offset, so daylight saving time is handled for you.
  • The zone is stored as a symlink: /etc/localtime points into /usr/share/zoneinfo. set-timezone just updates it (and /etc/timezone on Debian-style systems).
  • Servers usually run in UTC. Logs from many machines then sort and compare without conversions. Keep display zones for users.
  • NTP: System clock synchronized: yes means a time service (systemd-timesyncd, chrony) has recently corrected the clock. set-time fails while NTP is active.
  • Per-process zone: set TZ=... for one command, or export TZ in a script, instead of changing the machine setting.
  • Scripts: prefer timedatectl show -p Timezone --value over parsing the status table.
  • Containers share the host kernel clock; they only choose a zone (via TZ or a mounted /etc/localtime), they do not set the time.