Operations 4 min read

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

This guide explains three ways to change a Linux system's timezone to China Standard Time (CST, GMT+8) – using the timedatectl command, manually linking /etc/localtime, and setting the TZ environment variable for temporary adjustments.

Open Source Linux
Open Source Linux
Open Source Linux
How to Set Linux Timezone to CST (Asia/Shanghai) Using timedatectl and Manual Methods

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

Method 1: Use timedatectl (recommended for most modern distributions)

Check the current timezone: timedatectl The output shows fields such as Local time, Universal time, RTC time and Time zone (e.g., Asia/Shanghai ).

List available timezones containing Shanghai: timedatectl list-timezones | grep Shanghai The result should include Asia/Shanghai .

Set the timezone to CST (Asia/Shanghai): sudo timedatectl set-timezone Asia/Shanghai Verify the change: timedatectl The output should display Time zone: Asia/Shanghai (CST, +0800) .

Method 2: Manually link /etc/localtime

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

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

Validate the change: date The output should show the current time in CST (GMT+8).

Method 3: Set the TZ environment variable (temporary effect)

If you only need a temporary adjustment, set the TZ variable in the current session: export TZ="Asia/Shanghai" Then verify with: date Note: This method only affects the current shell session; it is lost after a reboot or when opening a new terminal.

Important Considerations

Using timedatectl is the recommended approach for modern Linux distributions.

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

The /etc/localtime linking method is useful for older Linux versions 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.

TimezoneSystem AdministrationtimedatectlAsia/ShanghaiCST
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

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.