1、安装ntpdate,同步标准时间
zce@ubuntu:~$ sudo apt install ntpdate
输入管理员密码确认安装
zce@ubuntu:~$ sudo apt install ntpdate [sudo] zce 的密码: 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 ntpdate 已经是最新版 (1:4.2.8p10+dfsg-5ubuntu7.3)。 下列软件包是自动安装的并且现在不需要了: gir1.2-goa-1.0 gir1.2-snapd-1 使用'sudo apt autoremove'来卸载它(它们)。 升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。 zce@ubuntu:~$
这里之前我已经安装过了,因此只显示已经是最新版
有些文章提供的方法是上面三种操作,但由于没有设置BIOS时间,修改后的时间和Windows系统的并不一致,不确定是哪个时区的。
2、修改时区
(1)
zce@ubuntu:~$ tzselect Please identify a location so that time zone rules can be set correctly. Please select a continent, ocean, "coord", or "TZ". 1) Africa 2) Americas 3) Antarctica 4) Asia 5) Atlantic Ocean 6) Australia 7) Europe 8) Indian Ocean 9) Pacific Ocean 10) coord - I want to use geographical coordinates. 11) TZ - I want to specify the time zone using the Posix TZ format. #? 4
(2)
Please select a country whose clocks agree with yours. 1) Afghanistan 29) Kyrgyzstan 2) Antarctica 30) Laos 3) Armenia 31) Lebanon 4) Azerbaijan 32) Macau 5) Bahrain 33) Malaysia 6) Bangladesh 34) Mongolia 7) Bhutan 35) Myanmar (Burma) 8) Brunei 36) Nepal 9) Cambodia 37) Oman 10) China 38) Pakistan 11) Christmas Island 39) Palestine 12) Cocos (Keeling) Islands 40) Philippines 13) Cyprus 41) Qatar 14) East Timor 42) Réunion 15) French S. Terr. 43) Russia 16) Georgia 44) Saudi Arabia 17) Hong Kong 45) Seychelles 18) India 46) Singapore 19) Indonesia 47) Sri Lanka 20) Iran 48) Syria 21) Iraq 49) Taiwan 22) Israel 50) Tajikistan 23) Japan 51) Thailand 24) Jordan 52) Turkmenistan 25) Kazakhstan 53) United Arab Emirates 26) Korea (North) 54) Uzbekistan 27) Korea (South) 55) Vietnam 28) Kuwait 56) Yemen #? 10
(3)
Please select one of the following time zone regions. 1) Beijing Time 2) Xinjiang Time, Vostok #? 1
(4)
The following information has been given: China Beijing Time Therefore TZ='Asia/Shanghai' will be used. Selected time is now: Thu Sep 7 15:01:32 CST 2023. Universal Time is now: Thu Sep 7 07:01:32 UTC 2023. 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
(5) 复制文件到/etc目录下
zce@ubuntu:~$ sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [sudo] zce 的密码:
输入管理员密码即可
(6)查看修改结果
zce@ubuntu:~$ date -R Thu, 07 Sep 2023 15:06:47 +0800
发现此时时间已经和windows系统一致了,重启ubuntu虚拟机即可。
标签:zce,同步,TZ,ubuntu,Asia,Ubuntu,时间,软件包,sudo From: https://www.cnblogs.com/Zhouce/p/17685002.html