若绾 若绾
  • 分类
    • 技术
  • 基准跑分
  • 信用卡
  • 摄影
  • 音乐
  • 关于
首页 技术 Linux系统 [Linux指南] 记录一下Ubuntu更换软件源的具体步骤

[Linux指南] 记录一下Ubuntu更换软件源的具体步骤

Royc30ne 2 年前

查找可用的Ubuntu软件源

首先,需要查找可用的Ubuntu软件源。我们可以在网络上找到一些可用的Ubuntu软件源,也可以在国内的一些开源镜像站点上查找。建议选择离自己地理位置较近的Ubuntu软件源,以获得更快的下载速度。

备份Ubuntu默认软件源

在更换Ubuntu软件源之前,建议备份原有的软件源列表,以便在需要时可以恢复。备份方法是将默认软件源列表文件复制到其他位置并重命名,例如:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

更换Ubuntu软件源

更换Ubuntu软件源需要编辑 /etc/apt/sources.list 文件。使用文本编辑器打开文件并注释掉原有的软件源(在行首加上 # 符号),然后添加新的软件源地址。例如,我们可以使用清华大学的开源镜像站点作为新的Ubuntu软件源地址:

#deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted
#deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
#deb http://archive.ubuntu.com/ubuntu/ focal universe
#deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
#deb http://archive.ubuntu.com/ubuntu/ focal multiverse
#deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
#deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
#deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
#deb http://security.ubuntu.com/ubuntu/ focal-security universe
#deb http://security.ubuntu.com/ubuntu/ focal-security 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 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 或 deb-src 开头,分别表示二进制文件和源代码文件的地址。

更新软件源缓存

更换完Ubuntu软件源之后,需要更新软件源缓存。可以使用以下命令更新缓存:

sudo apt update & apt upgrade

如何验证更换Ubuntu软件源的效果?

更换Ubuntu软件源之后,可以使用以下命令验证新的软件源是否生效:

apt-cache policy package-name

其中,package-name 是软件包的名称,可以输入任意已安装的软件包名称来验证。如果软件包可以从新的软件源下载,则说明更换Ubuntu软件源成功。

Appendix: 国内常用源

#网易163源

deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
# deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
# deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse

#阿里云源

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

#清华源

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.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

FAQ

1. 更换Ubuntu软件源会影响系统安全性吗?

不会。更换Ubuntu软件源并不会影响系统的安全性,只是会改变软件包的来源。建议使用经过认证和验证的官方软件源或者可信的开源镜像站点。

2. 如何查找可用的Ubuntu软件源地址?

可以在网络上搜索可用的Ubuntu软件源地址,也可以在国内的一些开源镜像站点上查找。建议选择离自己地理位置较近的Ubuntu软件源,以获得更快的下载速度。

3. 更换Ubuntu软件源会导致软件包版本冲突吗?

可能会。更换Ubuntu软件源可能会导致软件包版本冲突或者依赖关系不满足等问题。建议在更换Ubuntu软件源前备份原有的软件源列表,并根据实际情况选择合适的软件源地址。

4. 如何恢复到默认的Ubuntu软件源?

可以按照本文中提到的步骤进行恢复,需要注意备份当前的软件源列表、更新软件源缓存等步骤。

5. 更换Ubuntu软件源是否会影响已安装的软件包?

不会。更换Ubuntu软件源并不会影响已安装的软件包,只是会改变以后安装、更新、卸载软件包时的来源。已安装的软件包

# Linux# Ubuntu# VPS# 换源# 服务器
0
Royc30ne
万头攒动火树银花之处不必找我,若与相见,我在各种灯火交集处

评论 (0)

返回
    发表评论

猜你喜欢

  • Chevereto V4的进阶使用:加入图片审核及儿童色情鉴黄机制
  • Chevereto V4的进阶使用:挂载外部对象存储拓展存储空间
  • 教你如何使用 Docker 安装 Chevereto V4 搭建属于自己的图床
  • [Linux指南]手把手教你配置Ubuntu下的CUDA、cuDNN环境
  • [Linux指南]查看网卡配置及切换网卡工作模式
Royc30ne
万头攒动火树银花之处不必找我,若与相见,我在各种灯火交集处
22
文章
2
评论
6
获赞

最新内容

Chevereto V4的进阶使用:加入图片审核及儿童色情鉴黄机制
2 年前
Chevereto V4的进阶使用:挂载外部对象存储拓展存储空间
2 年前
教你如何使用 Docker 安装 Chevereto V4 搭建属于自己的图床
2 年前
Creative Commons License

本作品采用知识共享署名-非商业性4.0国际许可协议进行许可。

  • xLog
  • RSS
  • Email
  • 友链
  • 隐私政策
  • 开往
Copyright © 2021-2025 若绾. 萌ICP备20239880号.
友情链接: KPFD BlogWall BlogFinder 张洪Heo 又见苍岚 淇云博客
  • 分类
    • 技术
  • 基准跑分
  • 信用卡
  • 摄影
  • 音乐
  • 关于