如何解决apt update 时遇到的问题

发布时间:2023年12月18日

apt update 时报错
在这里插入图片描述

Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Err:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease
302 Found [IP: 91.189.91.39 80]
Err:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
302 Found [IP: 91.189.91.38 80]
Err:4 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
302 Found [IP: 91.189.91.39 80]
Reading package lists… Done
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
E: The repository ‘http://us.archive.ubuntu.com/ubuntu bionic InRelease’ is no longer signed.
E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/bionic/InRelease 302 Found [IP: 91.189.91.39 80]
E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease 302 Found [IP: 91.189.91.38 80]
E: The repository ‘http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease’ is no longer signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease 302 Found [IP: 91.189.91.39 80]
E: The repository ‘http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease’ is no longer signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

1. 查看ubuntu版本

cat /etc/lsb-release

2. 复制对应版本的阿里云镜像

阿里云镜像

3. 用上一步复制的阿里云镜像替换文件/etc/apt/sources.list中的内容

可以使用命令
因为sudo只对最近的一个命令有用,所以不能用
sudo echo “” >文件名,这样sudo只对echo有用,对写入命令无效

echo "" | sudo tee /etc/apt/sources.list #清空文件内容
echo "复制的内容" | sudo tee /etc/apt/sources.list #写入
文章来源:https://blog.csdn.net/nyyngh/article/details/135058068
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。