解决Ubuntu apt update更新太慢的问题

在安装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

参考

  1. Ubuntu修改软件源的方法
  2. ubuntu源的区分
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值