查看当前时间及时区
Bash
date -R
#Fri, 11 Apr 2025 00:05:08 +0000
运行tzselect,依次选择Asia – China – Beijing
Bash
tzselect
#Please identify a location so that time zone rules can be set correctly.
#Please select a continent, ocean, "coord", or "TZ".
#1) Africa 7) Europe
#2) Americas 8) Indian Ocean
#3) Antarctica 9) Pacific Ocean
#4) Asia 10) coord - I want to use geographical coordinates.
#5) Atlantic Ocean 11) TZ - I want to specify the timezone using the Posix TZ format.
#6) Australia
#? 4
#Please select a country whose clocks agree with yours.
# 1) Afghanistan 13) Cocos (Keeling) Islands 25) Jordan 37) Nepal 49) Syria
# 2) Antarctica 14) Cyprus 26) Kazakhstan 38) Oman 50) Taiwan
# 3) Armenia 15) East Timor 27) Korea (North) 39) Pakistan 51) Tajikistan
# 4) Australia 16) French S. Terr. 28) Korea (South) 40) Palestine 52) Thailand
# 5) Azerbaijan 17) Georgia 29) Kuwait 41) Philippines 53) Turkmenistan
# 6) Bahrain 18) Hong Kong 30) Kyrgyzstan 42) Qatar 54) United Arab Emirates
# 7) Bangladesh 19) India 31) Laos 43) Réunion 55) Uzbekistan
# 8) Bhutan 20) Indonesia 32) Lebanon 44) Russia 56) Vietnam
# 9) Brunei 21) Iran 33) Macau 45) Saudi Arabia 57) Yemen
#10) Cambodia 22) Iraq 34) Malaysia 46) Seychelles
#11) China 23) Israel 35) Mongolia 47) Singapore
#12) Christmas Island 24) Japan 36) Myanmar (Burma) 48) Sri Lanka
#? 11
#Please select one of the following timezones.
#1) Beijing Time
#2) Xinjiang Time
#? 1
#The following information has been given:
# China
# Beijing Time
#Therefore TZ='Asia/Shanghai' will be used.
#Selected time is now: Fri Apr 11 08:05:54 CST 2025.
#Universal Time is now: Fri Apr 11 00:05:54 UTC 2025.
#Is the above information OK?
#1) Yes
#2) No
#? 1
#You can make this change permanent for yourself by appending the line
# TZ='Asia/Shanghai'; export TZ
#to the file '.profile' in your home directory; then log out and log in again.
#Here is that TZ value again, this time on standard output so that you
#can use the /usr/bin/tzselect command in shell scripts:
#Asia/Shanghai
复制文件至etc
Bash
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
检查
Bash
date -R
#Fri, 11 Apr 2025 08:06:12 +0800
参考资料:Ubuntu修改时区和更新时间