1、有时候想更新系统,发现更新失败
sudo apt-get update
2、这时候可以考虑更新系统源,因为ubuntu默认的网站应该是*的,速度慢而且可能被墙
可以从清华镜像官网获取系统源:ubuntu清华镜像网站
3、备份原来的更新源
cp /etc/apt/sources.list /etc/apt/sources.list.bk
4、sudo权限打开更新源配置文件,将清华的更新源替换
sudo vi /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
5、保存成功后,再次更新
sudo apt-get update -y
6、此时还是有可能更新不成功,如我自己碰到的,
因为是因为没有公钥,需要下载一份,执行命令:
看网友的案例,有些可能需要下图的两个公钥不一样,所以需要下载两个公钥
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com FCEF32E745F2C3D5
mi@mi-OptiPlex-7040:~/work/paipai$ sudo apt-get update -y
命中:1 http://ppa.launchpad.net/git-core/ppa/ubuntu xenial InRelease
命中:2 http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial InRelease
获取:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease [265 kB]
错误:15 http://pkg.jenkins-ci.org/debian-stable binary/ Release.gpg
由于没有公钥,无法验证下列签名: NO_PUBKEY FCEF32E745F2C3D5
获取:17 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/restricted i386 Packages [8,112 B]
获取:18 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/restricted Translation-zh_CN [1,324 B]
获取:70 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security/universe DEP-11 64x64 Icons [46.0 kB]
获取:71 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security/multiverse amd64 Packages [14.8 kB]
获取:72 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security/multiverse i386 Packages [2,520 B]
获取:73 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security/multiverse Translation-en [3,160 B]
已下载 40.9 MB,耗时 1分 56秒 (350 kB/s)(appstreamcli:27147): GLib-CRITICAL **: g_strchug: assertion 'string != NULL' failed
(appstreamcli:27147): GLib-CRITICAL **: g_strchomp: assertion 'string != NULL' failed
AppStream cache update completed, but some metadata was ignored due to errors.
正在读取软件包列表... 完成
W: 校验数字签名时出错。此仓库未被更新,所以仍然使用此前的索引文件。GPG 错误:http://pkg.jenkins-ci.org/debian-stable binary/ Release: 由于没有公钥,无法验证下列签名: NO_PUBKEY FCEF32E745F2C3D5
W: 无法下载 http://pkg.jenkins-ci.org/debian-stable/binary/Release.gpg 由于没有公钥,无法验证下列签名: NO_PUBKEY FCEF32E745F2C3D5
W: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件。
7、再次更新:
sudo apt-get update -y
参考:
https://www.laozuo.org/11110.html
https://www.laozuo.org/10783.html