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路径保持不变,国内镜像使用与官方相同的签名密钥,无需修改。
  • 网络环境:若替换后出现连接超时,可尝试切换其他镜像源(如清华或中科大)。
    完成替换后,软件下载速度将显著提升。如需回滚,可通过备份文件恢复原始配置。
相关推荐
Sumlll_1 天前
Ubuntu系统下QEMU的安装与RISC-V的测试
linux·ubuntu·risc-v
猫头虎1 天前
2025最新OpenEuler系统安装MySQL的详细教程
linux·服务器·数据库·sql·mysql·macos·openeuler
晚风吹人醒.1 天前
SSH远程管理及访问控制
linux·运维·ssh·scp·xshell·访问控制·远程管理
Uncertainty!!1 天前
Linux多用户情况下个别用户输入密码后黑屏
linux·远程连接
necessary6531 天前
使用Clion查看linux环境中的PG源码
linux·运维·服务器
小猪佩奇TONY1 天前
Linux 内核学习(14) --- linux x86-32 虚拟地址空间
linux·学习
Lam㊣2 天前
Centos 7 系统docker:更换镜像源
linux·docker·centos
FL16238631292 天前
win11+WSL+Ubuntu-xrdp+远程桌面闪退+黑屏闪退解决
linux·运维·ubuntu
石头5302 天前
Kubernetes监控全栈解决方案:从零搭建Prometheus+Grafana监控体系
linux
ha20428941942 天前
Linux操作系统学习记录之---TcpSocket
linux·网络·c++·学习