apt-get update报错解决方法

前言

       经过反复折腾,总结一下,最后最有效的还是是从别的ubuntu中复制一份source.list过来,其他的方法都会有各种各样的后遗症。

一 出错现象

现象

kmao@lkmao-ubuntu:~/thrift/thrift-0.16.0$ sudo apt-get update
忽略:1 https://mirrors.cloud.tencent.com/ubuntu impish InRelease
忽略:2 https://mirrors.cloud.tencent.com/ubuntu impish-updates InRelease
忽略:3 https://mirrors.cloud.tencent.com/ubuntu impish-backports InRelease
忽略:4 https://mirrors.cloud.tencent.com/ubuntu impish-security InRelease
错误:5 https://mirrors.cloud.tencent.com/ubuntu impish Release
  404  Not Found [IP: 222.73.132.205 443]
错误:6 https://mirrors.cloud.tencent.com/ubuntu impish-updates Release
  404  Not Found [IP: 222.73.132.205 443]
错误:7 https://mirrors.cloud.tencent.com/ubuntu impish-backports Release
  404  Not Found [IP: 222.73.132.205 443]
错误:8 https://mirrors.cloud.tencent.com/ubuntu impish-security Release
  404  Not Found [IP: 222.73.132.205 443]
正在读取软件包列表... 完成
E: 仓库 “https://mirrors.cloud.tencent.com/ubuntu impish Release” 不再含有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
E: 仓库 “https://mirrors.cloud.tencent.com/ubuntu impish-updates Release” 不再含有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
E: 仓库 “https://mirrors.cloud.tencent.com/ubuntu impish-backports Release” 不再含有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
E: 仓库 “https://mirrors.cloud.tencent.com/ubuntu impish-security Release” 不再含有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
lkmao@lkmao-ubuntu:~/thrift/thrift-0.16.0$ 

   出错解析    

         这个错误呢,我的起因是因为以前改过/etc/apt/source.list文件,我觉得这种问题最快的解决方法就是,删掉它,然后重新弄一个管用的/etc/apt/source.list过来.

        大家看到/etc目录,要有那种第一反应就是,啊,这个是linux启动配置目录,然后再看到apt,就会联想到,啊,原来是apt软件在etc目录的配置目录,就是apt软件的配置文件,如果能有这个觉悟,其他的就大胆联想,大胆尝试吧。

二 解决方案

1.进入/etc/apt/目录,将source.list文件重命名为source.list.backup

2,新建source.list文件

3.将下面的内容放到source.list文件中

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://archive.ubuntu.com/ubuntu/ focal universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security multiverse

然后就可以$ sudo apt-get update

kmao@lkmao-ubuntu:/etc/apt$ sudo apt-get update
获取:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
获取:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
获取:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
获取:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
获取:5 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1,705 kB]
/*略*/
获取:108 http://archive.ubuntu.com/ubuntu focal-backports/universe DEP-11 64x64@2 Icons [29 B]
获取:109 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [860 B]
获取:110 http://archive.ubuntu.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B]
已下载 51.8 MB,耗时 20秒 (2,623 kB/s)                                         
正在读取软件包列表... 完成

lkmao@lkmao-ubuntu:/etc/apt$

三 如果直接删除source.list会怎么样?

这个简单,直接重命名就可以,现象也很简单,如下所示:

lkmao@lkmao-ubuntu:/etc/apt$ sudo apt-get update
正在读取软件包列表... 完成

试完了,记得把名字改回来。

四 如果还不能解决问题,怎么办?

        新安装一个虚拟机,将虚拟机中的/etc/apt目录中的文件打包,然后复制到出问题的ubuntu虚拟机中。

验证下:(⊙o⊙),我都安装新的系统了,为啥还要解决这个问题啊?用新的。

总结

        加油。

### 解决 `sudo apt-get update` 的 GPG 错误 当遇到 `sudo apt-get update` 命令返回 GPG 错误时,通常是因为系统无法验证软件包源的签名。以下是几种常见的解决方案: #### 方法一:导入缺失的公钥 如果错误信息指出缺少某个特定的公钥,则可以通过以下命令来获取并安装该公钥: ```bash sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 缺失的公钥ID ``` 例如,假设报错显示需要 ID 为 ABCDEF1234567890 的密钥,则应运行上述命令中的相应部分[^1]。 #### 方法二:清理并重新初始化 APT 密钥环 有时整个 APT 密钥链可能损坏或不一致。可以尝试删除现有的信任数据库文件夹再重建它: ```bash cd /etc/apt sudo mv trusted.gpg{,.bak} sudo mv trusted.gpg.d{,.bak} sudo apt-get clean all sudo apt-get update ``` 这会重置所有的已知发布者认证状态,并强制APT工具再次下载必要的元数据和签名信息[^3]。 #### 方法三:检查网络连接设置 对于某些企业内部网环境下的计算机来说,可能会因为代理服务器或其他形式的身份验证机制而导致 "Clearsigned file isn't valid" 类型的问题。确认当前机器能够正常访问外部互联网资源非常重要;必要时配置好HTTP/HTTPS_PROXY变量或者调整/etc/environment 文件内的相关内容[^4]。 通过以上三种方式之一应该能有效解决大多数情况下由GPG引起的apt-get更新失败问题。具体采取哪种方案取决于实际发生的错误详情以及用户的操作系统的具体情况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

千册

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值