Ubuntu 24.04-国内镜像源替换

替换步骤(以阿里云镜像为例)

  • 备份原始配置
    (防止误操作):
bash 复制代码
sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
  • 修改主仓库配置
    将原条目:

    plaintextTypes: deb
    URIs: http://cn.archive.ubuntu.com/ubuntu/
    Suites: noble noble-updates noble-backports
    Components: main restricted universe multiverse
    Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

替换为:

复制代码
plaintextTypes: deb
URIs: https://mirrors.aliyun.com/ubuntu/  # 改为阿里云镜像
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
  • 修改安全源配置
    将原条目:

    plaintextTypes: deb
    URIs: http://security.ubuntu.com/ubuntu/
    Suites: noble-security
    Components: main restricted universe multiverse
    Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

替换为:

复制代码
plaintextTypes: deb
URIs: https://mirrors.aliyun.com/ubuntu/  # 改为阿里云镜像
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

验证与更新

  • 检查配置文件:
bash 复制代码
cat /etc/apt/sources.list.d/ubuntu.sources  # 确认URI已替换为国内镜像
  • 更新软件包列表:
bash 复制代码
sudo apt update  # 若显示从mirrors.aliyun.com获取索引,则成功

其他国内镜像源选项

注意事项

  • 格式一致性:Ubuntu 24.04起使用DEB822格式(ubuntu.sources文件),不可替换为传统sources.list格式,否则会导致配置失效。
  • 密钥验证:Signed-By路径保持不变,国内镜像使用与官方相同的签名密钥,无需修改。
  • 网络环境:若替换后出现连接超时,可尝试切换其他镜像源(如清华或中科大)。
    完成替换后,软件下载速度将显著提升。如需回滚,可通过备份文件恢复原始配置。
相关推荐
orion571 天前
Missing Semester Class1:course overview and introduction of shell
linux
用户120487221611 天前
Linux驱动编译与加载
linux·嵌入式
用户805533698031 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698031 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
七歌杜金房2 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia3 天前
linux curl命令详解_curl详解
linux
扛枪的书生3 天前
Linux 网络管理器用法速查
linux
顺风尿一寸3 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
XIAOHEZIcode3 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫4 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux