linux默认使用UTC区时,查看起来不方便。因此可以改变区时为亚洲上海。改动方法如下:
使用date
命令查看时间
date
结果是UTC区时:
Tue Jan 4 07:45:25 UTC 2022
改动区时命令:(使用时间2022-1-4,网络上博客大多给出的是 sudo tzconfig
,但是该命令已经不支持了)
dpkg-reconfigure tzdata
然后就会让选择洲和城市,依次选择亚洲(选择Asia对应序号)和上海(对应序号)就可以了。
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by
presenting a list of cities, representing the time zones in which they are located.
1. Africa 3. Antarctica 5. Arctic 7. Atlantic 9. Indian 11. SystemV 13. Etc
2. America 4. Australia 6. Asia 8. Europe 10. Pacific 12. US
Geographic area: 6
Please select the city or region corresponding to your time zone.
...
10. Bahrain 25. Dushanbe 40. Karachi 55. Novokuznetsk 70. Shanghai 85. Vientiane
...
Time zone: 70
Current default time zone: 'Asia/Shanghai'
Local time is now: Tue Jan 4 15:47:38 CST 2022.
Universal Time is now: Tue Jan 4 07:47:38 UTC 2022.
如果提示tzdata is not installed
,安装即可:
sudo apt-get install tzdata
安装后会直接提示修改区时,直接参考上面的操作,进行设置即可。