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.
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:
timedatectlMethod 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/localtimeConfirm the change:
dateMethod 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
