WSL Ubuntu 24.04 配置阿里云镜像源
如果你正在 Windows Subsystem for Linux (WSL) 中使用最新的 Ubuntu 24.04 LTS(代号 Noble Numbat),可能会发现从默认的官方源下载软件包速度较慢。将其替换为阿里云镜像站,可以极大地提升下载速度。
为什么要换源?
默认的软件源服务器位于国外,在国内网络环境下访问速度可能不理想。将其替换为阿里云镜像站,相当于在国内有了一个完整的 Ubuntu 软件仓库副本,下载速度会得到质的飞跃,无论是安装新软件还是更新系统,都会更加迅速。
阿里云镜像站地址: https://mirrors.aliyun.com/ubuntu/
配置步骤
重要提示: Ubuntu 24.04 引入了一个新的软件源配置方式。传统的 sources.list 文件依然有效,但系统默认使用新的 /etc/apt/sources.list.d/ubuntu.sources 文件。我们将介绍两种方法,推荐使用方法二以符合新系统的规范。
方法一:修改传统的 sources.list 文件(通用方法)
如果你习惯传统方式,或者你的系统仍主要使用 sources.list,可以按此方法操作。
-
备份原始源列表(好习惯) 首先,我们备份一下原来的源列表,以防万一。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak -
清空并编辑 sources.list 文件 使用你喜欢的文本编辑器(如
nano或vim)打开源列表文件。这里以nano为例:sudo nano /etc/apt/sources.list将文件内的所有内容删除,然后复制并粘贴以下为 Ubuntu 24.04 配置好的阿里云源内容:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse

