Ubuntu24.04更换国内镜像源
时间: 2025-01-29 14:38:41 浏览: 319
### 更改Ubuntu 24.04系统的软件包镜像源
对于希望提升软件包下载速度的用户来说,将默认的国外服务器更改为国内服务器是一个有效的方法。鉴于Ubuntu 24.04版本中源地址配置文件发生了变化,不再使用传统的`sources.list`文件而是采用了新的路径 `/etc/apt/sources.list.d/ubuntu.sources`。
#### 备份现有源文件
为了防止意外情况的发生,在修改之前先备份现有的源文件是非常重要的操作[^3]:
```bash
sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
```
#### 修改源文件指向国内镜像
接下来编辑新位置下的源文件来指定使用阿里云或其他国内镜像站作为新的APT仓库地址:
```bash
sudo vim /etc/apt/sources.list.d/ubuntu.sources
```
在打开后的文件内替换原有的URL为如下所示的内容之一(这里以阿里云为例),并保存退出:
```plaintext
deb http://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
```
完成上述更改后,通过执行以下命令刷新本地索引以便立即生效这些改动[^2]:
```bash
sudo apt update
```
现在应该能够享受到更快捷稳定的软件安装体验了。
阅读全文
相关推荐
















