在安装Ubuntu后一般自己都会用apt update更新一下,但有时候网速会非常慢难以忍受,因为对应的服务器是在国外的
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
我用的版本是Ubuntu18.04,所以版本号为bionic
如何让update更快
现在像清华和阿里都有服务器存放这些源的,我们把对应的http网址替换成http://mirrors.aliyun.com/ubuntu/
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对应的版本:
# 默认注释了源码镜像以提高 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
操作步骤
# 做个备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 编辑文件内容 把文件里的内容全部替换成上面的阿里源或者清华源
sudo gedit /etc/apt/sources.list
# 这个时候你会发现更新速度很快很快
sudo apt-get update
sudo apt-get upgrade
注意一定要选择好自己Ubuntu对应的版本,像我Ubuntu版本是18.04,所以用的是bionic,如果Ubuntu版本是16.04就是xenial,如果是20.04那么就是focal,选错版本会出一堆莫名其妙的问题比如
The following packages have unmet dependencies:
build-essential : Depends: libc6-dev but it is not going to be installed or
libc-dev
Depends: g++ (>= 4:5.2) but it is not going to be installed
Depends: dpkg-dev (>= 1.17.11) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
以及
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/freedom/postgresql-12.2':
configure: error: C compiler cannot create executables
See `config.log' for more details
还有
dpkg: error processing archive /var/cache/apt/archives/wireless-regdb_2020.11.20-0ubuntu1~16.04.2_all.deb (--unpack):
trying to overwrite '/lib/crda/pubkeys/sforshee.key.pub.pem', which is also in package crda 3.18-1build1
Errors were encountered while processing:
/var/cache/apt/archives/wireless-regdb_2020.11.20-0ubuntu1~16.04.2_all.deb