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路径保持不变,国内镜像使用与官方相同的签名密钥,无需修改。
  • 网络环境:若替换后出现连接超时,可尝试切换其他镜像源(如清华或中科大)。
    完成替换后,软件下载速度将显著提升。如需回滚,可通过备份文件恢复原始配置。
相关推荐
有谁看见我的剑了?7 小时前
linux 添加硬盘后系统识别不到硬盘处理
linux·运维·服务器
yc_12248 小时前
用 Visual Studio 远程调试 Linux:从零到流畅的完整指南
linux·ide·visual studio
计算机安禾8 小时前
【Linux从入门到精通】第31篇:防火墙漫谈——iptables与firewalld防护指南
linux·运维·php
下一页盛夏花开9 小时前
ubuntu 20中安装QT以后出现红色空心断点
linux·运维·ubuntu
sanshanjianke9 小时前
Thunderobot 911ME 笔记本 Linux 风扇控制研究
linux
fengyehongWorld12 小时前
TeraTerm ttl脚本登录wsl
linux·teraterm
乌托邦的逃亡者13 小时前
Linux中如何检测IP冲突
linux·运维·tcp/ip
一曦的后花园13 小时前
linux搭建promethes并对接node-exporter指标
linux·运维·服务器
乌托邦的逃亡者13 小时前
CentOS/Openeuler主机中,为一个网卡设置多个IP地址
linux·运维·网络·tcp/ip·centos
拾贰_C14 小时前
【OpenClaw | openai | QQ】 配置QQ qot机器人
运维·人工智能·ubuntu·面试·prompt