首页 > Sysadmin > 正文

Change Timezone and Time Synchronization on Linux

2026-10-30 Sysadmin

Verified: timedatectl timezone queries and lists were tested on Ubuntu 24.04 WSL; this article does not cover real reboots, physical RTC, or the default NTP service on every distribution.

When Linux time is wrong, it usually splits into two issues: the timezone determines how local time is displayed, and the NTP service keeps the system clock synced to network time. Recommended order: check status first, then change the timezone, then confirm sync status. Do not manually edit /etc/localtime.

Check current status

timedatectl status shows local time, UTC time, timezone, whether the system clock is synchronized, and NTP service status. To view only the timezone:

timedatectl show -p Timezone --value

Change timezone

List available names, then set one. For mainland China, use Asia/Shanghai:

timedatectl list-timezones | grep -E '^(Asia/Shanghai|Etc/UTC)$'
sudo timedatectl set-timezone Asia/Shanghai

set-timezone updates the /etc/localtime symlink.[1] The timezone parameter should use IANA names, not “Beijing Time” or UTC+8.

Verify after changing:

timedatectl status
date '+%F %T %Z %z'

Enable and check network sync

On systems where systemd provides time sync, view and enable NTP:

sudo timedatectl set-ntp true
timedatectl show -p NTPSynchronized -p NTP --value

yes means the feature is enabled or the clock has already synced; right after enabling, it may take time for network time and calibration to complete.[2] Use timedatectl status for an overview; on systems using chrony, run:

chronyc -N tracking

If the system has no chronyc, do not install anything blindly. Confirm the distribution’s time-sync stack first:

systemctl list-unit-files | grep -E 'systemd-timesyncd|chrony|ntp'

FAQ and rollback

Symptom Likely cause Action
Timezone is set but app shows old time App caches timezone or uses a fixed config Restart the app and check its environment variables
set-timezone permission error Non-admin user Run with an account that has admin privileges
NTPSynchronized: no Network down, service not started, or just enabled Check timedatectl status and service logs
Clock inconsistent inside container Containers share the host clock; timezone comes from the image or environment Check the host first, then the container’s /etc/localtime

To undo a timezone change, set the previous IANA name again:

sudo timedatectl set-timezone Etc/UTC

Do not use set-time as a substitute for NTP; manually setting system time can break certificates, logs, and scheduled tasks. For precise sync checks, follow the current distribution docs for chronyc or systemctl.

Test scope and limitations

This test was run on Ubuntu 24.04 WSL as root. We queried timedatectl status, filtered Asia/Shanghai and Etc/UTC, and read Timezone, NTPSynchronized, and NTP properties, observing timezone Asia/Shanghai, sync yes, NTP yes. No write operations that change user system timezones were performed, and real hardware RTC, persistence after reboot, and default services on Fedora/Arch were not verified.

References

Main commands were tested on WSL Ubuntu 24.04; some entries were only cross-checked against official docs and not executed live.