Operations 4 min read

Set Linux Timezone to CST (Asia/Shanghai) with timedatectl and Manual Methods

Learn step-by-step how to change a Linux system’s timezone to China Standard Time (CST, GMT+8) using the timedatectl command, manually linking /etc/localtime, or setting the TZ environment variable, including verification commands and important considerations.

Raymond Ops
Raymond Ops
Raymond Ops
Set Linux Timezone to CST (Asia/Shanghai) with timedatectl and Manual Methods

In Linux, you can set the timezone to CST (China Standard Time, GMT+8, also known as Asia/Shanghai) by following these steps.

Method 1: Using timedatectl (suitable for most modern distributions)

Check the current timezone: timedatectl List available timezones: timedatectl list-timezones | grep Shanghai Set the timezone to CST (Asia/Shanghai): sudo timedatectl set-timezone Asia/Shanghai Verify the change:

timedatectl

Method 2: Manually linking /etc/localtime

Backup the existing timezone file: sudo mv /etc/localtime /etc/localtime.bak Create a symbolic link to the CST zone file:

sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Confirm the change:

date

Method 3: Setting the TZ environment variable (temporary)

If you only need a temporary adjustment, export the TZ variable: export TZ="Asia/Shanghai" Verify with: date Note: This method only affects the current session and will be lost after a reboot or when opening a new terminal.

Important Notes

Using timedatectl is the recommended approach for modern Linux distributions.

Ensure your system clock (UTC) is correct; the timezone setting only changes the displayed time.

Modifying /etc/localtime is suitable for older systems that do not support timedatectl.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

TimezonetimedatectlCST
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.