Ubuntu换源详解,教你如何换源,并且解决常见的大坑
记一次极不愉快的一次经历
首先注意,换源必须选择合适的版本,不可以在网上找一个下载源就直接去换
出现错误1:
由于没有公钥,无法验证下列签名 :NO_PUBKEY
无法安全地用该源进行更新,所以默认禁用该源
注意网上可能会有这样的解决方法:
但是最好不要这样,我就因为这样以为解决了,结果在安装sudo apt install openssh-server
的过程中出现了
出现错误2:
错误1:E:软件包 openssh-server 还没有可供安装的候选者,错误2:E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系
这就代表着你目前使用的源和你目前使用的Ubuntu不一致,你需要选择正确的源。
E: 错误,pkgProblemResolver::Resolve 发生故障,这可能是有软件包被要求保持现状的缘故
那么我下面将介绍如何选择正确的源去解决上述问题,并且怎么去更新源,最后列出一些常用的源,供大家选择
选择源
首先大家查看自己的Ubuntu版本
系统名 | 版本名 |
---|---|
ubuntu22.04 | jammy |
ubuntu20.04 | focal |
ubuntu18.04 | bionic |
ubuntu16.04 | xenial |
ubuntu14.04 | trusty |
也可以使用lsb_release -c
查看
保证版本和自己的是一样的,比如下面就是20.04的版本
ubuntu 18.04(bionic) 配置如下
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
ubuntu 20.04(focal) 配置如下
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
剩余的可以去阿里云官方网站去找:
iyun.com/ubuntu/ focal-backports main restricted universe multiverse
剩余的可以去阿里云官方网站去找:
https://developer.aliyun.com/mirror/ubuntu