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路径保持不变,国内镜像使用与官方相同的签名密钥,无需修改。
  • 网络环境:若替换后出现连接超时,可尝试切换其他镜像源(如清华或中科大)。
    完成替换后,软件下载速度将显著提升。如需回滚,可通过备份文件恢复原始配置。
相关推荐
rayylee2 小时前
使用 Windows 自带 ssh 的 X11转发功能并配置 ssh 和 VSCode
linux·运维
枉费红笺2 小时前
Linux / macOS 环境下解压 ZIP 文件的标准命令与常用变体
linux·运维·macos
云游牧者2 小时前
ubuntu 22.04系统修改网卡名称方法
linux·运维·ubuntu
默|笙2 小时前
【Linux】进程控制(1)进程创建、终止
linux·运维·服务器
郝学胜-神的一滴2 小时前
Linux的pthread_self函数详解:多线程编程中的身份标识器
linux·运维·服务器·开发语言·c++·程序人生
小立爱学习2 小时前
ARM64 指令 --- CCMP/CSEL
linux·c语言
jimy12 小时前
程序崩溃free(): double free detected in tcache 2
linux·开发语言·数据结构·链表
松涛和鸣3 小时前
37、UDP网络编程入门
linux·服务器·前端·网络·udp·php
坐吃山猪3 小时前
Python命令行工具Click
linux·开发语言·python