参考:https://blog.csdn.net/qq_35451572/article/details/79516563
直接替换文件 /etc/apt/sources.list
的内容即可。
find /etc/apt/ -type f| grep -Ei 'sources' | xargs -I {} sed -i 's#http://security.ubuntu.com#http://mirrors.aliyun.com#g' {}
find /etc/apt/ -type f| grep -Ei 'sources' | xargs -I {} sed -i 's#http://archive.ubuntu.com#http://mirrors.aliyun.com#g' {}
如果执行 apt update
命令时遇到报错 NO_PUBKEY
,那么可以编辑 sources.list
文件,在每个 deb
后面加一个 [trusted=yes]
https://unix.stackexchange.com/questions/198000/bypass-gpg-signature-checks-only-for-a-single-repository/198454#198454
遇到阿里云的源也不好用了,在 sources.list
里面加上 [trusted=yes]
就可以了。
例如
deb [trusted=yes] http://localmachine/debian wheezy main
或者
deb [ allow-insecure=yes ] ...
或者使用如下命令
-
尝试使用
apt-get clean
命令清理缓存 -
尝试使用
apt-get update --allow-insecure-repositories
命令允许更新不安全的源; -
尝试使用
apt-get update --allow-unauthenticated
命令允许更新不受信任的源; -
尝试使用
apt-get update --allow-unauthenticated --allow-insecure-repositories
命令允许更新不受信任和不安全的源; -
尝试使用
apt-get update --allow-unauthenticated --allow-insecure-repositories --allow-releaseinfo-change
命令允许更新不受信任、不安全和发行信息变更的源; -
尝试使用
apt-get update --allow-unauthenticated --allow-insecure-repositories --allow-releaseinfo-change --allow-downgrades
命令允许更新不受信任、不安全、发行信息变更和降级的源; -
尝试使用
apt-get update --allow-unauthenticated --allow-insecure-repositories --allow-releaseinfo-change --allow-downgrades --allow-change-held-packages
命令允许更新不受信任、不安全、发行信息变更、降级和更改已安装软件包的源。
阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse
清华源
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
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
网易源
deb http://mirrors.163.com/ubuntu/ wily main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse