我最近在Raspberry Pi上安(ān)裝(zhuāng)了Ubuntu服務(wù)器。我從Ubuntu終端将其連接到Wi-Fi,并在安(ān)裝(zhuāng)任何要更新(xīn)系統的Linux系統後繼續進行操作(zuò)。
當我使用(yòng)“ sudo apt update”命令時,它給了我一個錯誤,這對我來說是唯一的。它抱怨該存儲庫的發行文(wén)件在一定時間内無效。
ERROR:Release file for http://ports.ubuntu.com/ubuntu-ports/dists/focal-security/InRelease is not valid yet (invalid for another 159d 15h 20min 52s). Updates for this repository will not be applied.
這是完整的輸出:
ubuntu@ubuntu:~$ sudo apt update
Hit:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
Get:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease [111 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease [98.3 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [107 kB]
Reading package lists... Done
E: Release file for http://ports.ubuntu.com/ubuntu-ports/dists/focal/InRelease is not valid yet (invalid for another 21d 23h 17min 25s). Updates for this repository will not be applied.
E: Release file for http://ports.ubuntu.com/ubuntu-ports/dists/focal-updates/InRelease is not valid yet (invalid for another 159d 15h 21min 2s). Updates for this repository will not be applied.
E: Release file for http://ports.ubuntu.com/ubuntu-ports/dists/focal-backports/InRelease is not valid yet (invalid for another 159d 15h 21min 32s). Updates for this repository will not be applied.
E: Release file for http://ports.ubuntu.com/ubuntu-ports/dists/focal-security/InRelease is not valid yet (invalid for another 159d 15h 20min 52s). Updates for this repository will not be applied.
錯誤的原因是系統時間與實際時間之間的差異。
您會看到,每個存儲庫文(wén)件都在某個日期簽名(míng),您可(kě)以通過查看發布文(wén)件來查看以下信息:
sudo head /var/lib/apt/lists/ports.ubuntu.com_ubuntu_dists_focal_InRelease
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Origin: Ubuntu
Label: Ubuntu
Suite: focal
Version: 20.04
Codename: focal
Date: Thu, 23 Apr 2020 17:33:17 UTC
Architectures: amd64 arm64 armhf i386 ppc64el riscv64 s390x
現在,由于某些原因,我的Ubuntu服務(wù)器上的時間過去了,這就是為(wèi)什麽Ubuntu抱怨發行文(wén)件在X天内還無效的原因。
如果您已連接到Internet,則可(kě)能(néng)需要等待幾分(fēn)鍾,系統才能(néng)同步時間。
如果它不起作(zuò)用(yòng),則可(kě)以強制系統将本地時間用(yòng)作(zuò)實時時鍾(硬件時鍾):
sudo timedatectl set-local-rtc 1
使用(yòng)timedatectl命令可(kě)以在Linux上配置時間,日期和更改時區(qū)。
您不需要重新(xīn)啓動。它可(kě)以立即工(gōng)作(zuò),您可(kě)以通過再次更新(xīn)Ubuntu系統來進行驗證。
如果問題得以解決,則可(kě)以将實時時鍾設置為(wèi)使用(yòng)UTC(Ubuntu建議)。
sudo timedatectl set-local-rtc 0