赞
踩
在使用sudo apt update
更新源时,发现报了一大堆错。例如
E: 仓库 “http://mirrors.aliyun.com/docker-ce/linux/debian ulyana Release” 没有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
W: 无法下载 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu/dists/focal/InRelease 不能连接到 ppa.launchpad.net:http: W: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件
起初我以为是源的问题,所以进行了换源。换源的方式有以下两种。
/etc/apt/sources.list
文件里的源备份源列表
Linux配置的默认源并不是国内的服务器,下载更新软件都比较慢。首先备份源列表文件sources.list
:
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup20221122 #备份源列表
修改源列表文件
sudo gedit /etc/apt/sources.list # 打开sources.list文件
编辑/etc/apt/sources.list
文件, 在文件最前面添加镜像源:
#阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
#中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
以上三种镜像源选择其中一个即可。
换源完成后更新即可。
sudo apt-get update
sudo apt-get upgrade
software&updates(软件和更新)
里进行换源
换源完成后更新即可。
sudo apt-get update
sudo apt-get upgrade
换成国内源,可以使下载速度更快,但是,换源后有些错误依旧没有解决,究其原因,这是因为以前添加的旧的ppa会导致很多问题,可能已经不可用了,所以,需要把它们删除或者注释掉。
首先,终端执行以下命令查看所有时效的ppa
sudo apt-get update | grep "Failed"
查找过程需要几分钟,需要耐心等待。
我这边时效的ppa有下面这个:
E: 仓库 “http://mirrors.aliyun.com/docker-ce/linux/debian ulyana Release” 没有 Release 文件。
接下来,进入/etc/apt/sources.list.d
目录下,打开对应ppa的.list文件
,注释掉里面的ppa
例如,我这边是docker-ce
的ppa问题,所以,我打开的是docker.list
文件。
# 进入目录
cd /etc/apt/sources.list.d
# 打开对应的.list文件
sudo gedit docker.list
打开后,将里面的ppa用#
号注释掉(当然,除了注释掉,也可以直接把这个文件移除,这边选择了注释的方式)。
最后,再次执行sudo apt update
,此时便不再报错了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。