我最近在Raspberry Pi上安装了Ubuntu服务器。我从Ubuntu终端将其连接到Wi-Fi,并在安装任何要更新系统的Linux系统后继续进行操作。
当我使用“ sudo apt update”命令时,它给了我一个错误,这对我来说是唯一的。它抱怨该存储库的发行文件在一定时间内无效。
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.
错误的原因是系统时间与实际时间之间的差异。
您会看到,每个存储库文件都在某个日期签名,您可以通过查看发布文件来查看以下信息:
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服务器上的时间过去了,这就是为什么Ubuntu抱怨发行文件在X天内还无效的原因。
如果您已连接到Internet,则可能需要等待几分钟,系统才能同步时间。
如果它不起作用,则可以强制系统将本地时间用作实时时钟(硬件时钟):
sudo timedatectl set-local-rtc 1
使用timedatectl命令可以在Linux上配置时间,日期和更改时区。
您不需要重新启动。它可以立即工作,您可以通过再次更新Ubuntu系统来进行验证。
如果问题得以解决,则可以将实时时钟设置为使用UTC(Ubuntu建议)。
sudo timedatectl set-local-rtc 0