为什么切换软件源?
当初次部署Ubuntu镜像时,会发现更新软件时速度非常慢,因为Ubuntu的软件都来自与国外,所下载或更新软件时的速度非常慢,此时就可以选择切换到国内的软件源来解决此问题。
更新Ubuntu软件源
国内的软件源有很多,比如一些互联网公司及各大高校等,较为常用的有阿里云源和清华源
阿里云源: http://mirrors.aliyun.com/ubuntu/
清华源: https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
1.获取软件源配置(二者任选其一)
- 清华源:
打开清华源链接,切换到自己所使用的Ubuntu版本,复制文本框中的配置信息
20.04 LTS版本:
# 默认注释了源码镜像以提高 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
- 阿里云源:
打开阿里云链接
点击进入Ubuntu
Ubuntu 20.04配置:
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
2.修改配置文件sources.list
现将原sources.list备份一下(如果后续修改错误还可以替换回来)
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
使用编辑器打开sources.list文件,并将1中复制的配置信息替换到sources.list中,然后保存退出
sudo gedit /etc/apt/sources.list
3.更新软件列表并升级软件
检索更新软件列表
sudo apt-get update
可以看到源都已经更新为清华源,如果使用的是阿里云源的配置,那此处就会从阿里云源中拉取:
更新软件
sudo apt-get upgrade
至此完成更新Ubuntu软件源整个过程
标签:mirrors,restricted,Ubuntu,切换,https,ubuntu,软件,main,multiverse From: https://www.cnblogs.com/Wangzx000/p/16726718.html