概述

目标:把系统软件源更换为清华源
步骤:
1、确定自己系统版本
2、备份原始文件
3、粘贴复制文件内容
4、源更新

1、查看系统信息

使用命令:hostnamectl status

qif@ubuntu:/bin$ hostnamectl status
   Static hostname: ubuntu
         Icon name: computer-vm
           Chassis: vm
        Machine ID: ed4295806008422ca5db8deed4b085dc
           Boot ID: 6b310719f323439e9e6cc4b036229bd0
    Virtualization: vmware
  Operating System: Ubuntu 20.04.3 LTS
            Kernel: Linux 5.11.0-34-generic
      Architecture: x86-64

在 Ubuntu 24.04 之前,Ubuntu 的软件源配置文件使用传统的 One-Line-Style,路径为/etc/apt/sources.list;从 Ubuntu 24.04 开始,Ubuntu 的软件源配置文件变更为 DEB822格式,路径为 /etc/apt/sources.list.d/ubuntu.sources。

我的机器版本是Ubuntu 20.04.3 LTS,所以我的文件路径为:/etc/apt/sources.list

2、备份原始文件

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

3、替换文件内容

将下方的源内容,直接替换掉里面的内容

sudo vi /etc/apt/sources.list

源内容

# 默认注释了源码镜像以提高 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 http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/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

更新

sudo apt-get update

附录

清华大学开源软件镜像站
参考文档

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐