【Ubuntu】Ubuntu 24.04 配置镜像源

【Ubuntu】Ubuntu 24.04 配置镜像源

零、起因

最近在虚拟机中安装了个ubuntu-24.04-desktop-amd64,默认是国外的软件源,很慢,故替换到国内。

壹、替换

源地址(阿里源)

其他版本的软件源文件内容看这里:https://developer.aliyun.com/mirror/ubuntu

软件源文件内容:

原位置(/etc/apt/sources.list

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-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed 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

新位置(/etc/apt/sources.list.d/ubuntu.sources

# 阿里云
Types: deb
URIs: http://mirrors.aliyun.com/ubuntu/
Suites: noble noble-updates noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

选择一种方式(新位置)写入到对应文件中去

更新

更新完软件源后即可使用更新后的镜像源~

更新软件源:

sudo apt-get update

更新软件(可选):

sudo apt-get upgrade

贰、参考

### 如何在Ubuntu上设置国内镜像源 #### 修改`sources.list`文件 为了提高软件包下载的速度,在Ubuntu系统中可以通过修改`/etc/apt/sources.list`文件来配置使用国内的镜像源。这一步骤适用于多种版本的Ubuntu操作系统。 对于希望备份原始`sources.list`文件的情况,可以执行命令: ```bash sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak ``` 接着创建新的`sources.list`文件并编辑它以指向所需的国内镜像源[^4]。 #### 使用清华大学镜像源作为例子 当选择清华大学镜像源时,可以在新建立的`sources.list`文件内加入如下内容(针对Ubuntu 20.04 LTS即Focal Fossa): ```plaintext deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse ``` 上述每一行代表了一个特定类型的仓库位置及其组件分类,确保覆盖了主要、受限、宇宙以及多元宇宙四个部分,并区分了稳定版(focal)、更新(focal-updates)、回溯支持(focal-backports)和安全补丁(focal-security)[^1]。 #### 利用阿里云镜像源 如果偏好于阿里云所提供的服务,则应访问官方提供的链接查看对应系统的具体路径,特别是要确认所使用的Ubuntu版本代号(Codename),比如对于Ubuntu 20.04 LTS来说就是"focal"[^2]。之后按照相似的方式编辑`sources.list`文件中的条目,只需更改URL至阿里云提供的相应地址即可。 完成以上任意一种方式的操作后,记得运行以下命令刷新APT缓存使改动生效: ```bash sudo apt update && sudo apt upgrade ``` 这样就可以利用更快速稳定的国内镜像源来进行后续的应用程序安装与系统升级工作了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

玉米子禾

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值