Ubuntu--更换软件源

本文详细介绍如何选择和配置Ubuntu的软件源,包括阿里云、中科大等镜像站点的ping测试结果,以及如何根据Ubuntu版本(如16.04、18.04)修改sources.list文件。此外,还解释了main、restricted、universe和multiverse组件的含义,以及Ubuntu版本代号信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.可用源列表

源地址ping测试 min/avg/max(ms)
阿里云mirrors.aliyun.com6.850/8.869/19.176
中科大mirrors.ustc.edu.cn30.355/35.616/50.826
网易mirrors.163.com7.026/8.235/18.526
清华大学mirrors.tuna.tsinghua.edu.cn30.747/32.264/33.513
东北大学mirror.neu.edu.cn44.784/46.145/48.763
兰州大学mirror.lzu.edu.cn55.342/56.719/61.365

在测试的时候,阿里云的源是最快的,另外网易的也挺快,不过网易不提供ubuntu16.04的源。选择源根据自己情况而定,优先选择延迟小的源。

2.复制源内容

点击阿里云的地址进入镜像网站,再点击ubuntu->帮助就会看到相应的源内容。
在这里插入图片描述

3.修改源文件

源列表文件位置:/etc/apt/sources.list,删除source.list文件中的内容,将阿里云的源直接复制粘贴过去。
ubuntu 16.04版本:

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

ubuntu 18.04版本:

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

4.更新源

修改了源之后要更新源文件才会生效。

sudo apt-get update

补充内容

1.源后面main restricted universe multiverse的含义

  • main: 完全的自由软件。
  • restricted: 不完全的自由软件。
  • universe: Ubuntu官方不提供支持与补丁,全靠社区支持。
  • multiverse: 非自由软件,完全不提供支持和补丁。

2.Ubuntu版本代号信息

代号版本
precise12.04
trusty14.04
vivid15.04
wily15.10
xenial16.04
yakkety16.10
zesty17.04
bionic18.04

参考网址: https://blog.csdn.net/pingsoli/article/details/68128188

### 如何在 Ubuntu 22.04 上更换软件源 #### 备份原始列表文件 为了防止出现问题,建议先备份 `/etc/apt/sources.list` 文件。可以使用以下命令来创建备份: ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` 此操作会将现有的 `sources.list` 文件复制并重命名为 `sources.list.bak`[^1]。 #### 编辑新的列表文件 接下来编辑 `/etc/apt/sources.list` 文件以替换为国内镜像站的内容。这里提供阿里云的配置作为例子: 对于主版本库和其他官方仓库,可采用如下设置: ```plaintext deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse ``` 上述 URL 中,“jammy”代表了 Ubuntu 22.04 的代号;如果读者使用的不是该特定版本,则需相应调整这部分内容。 完成修改之后保存文件退出编辑器。 #### 更新本地包索引 最后一步是要让系统知道已经改变了软件源的位置。这可以通过运行下面这条指令实现: ```bash sudo apt-get update ``` 执行完毕后就可以享受更快捷稳定的软件下载体验了。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值