【原创】Debian 10 更换 aliyun apt-get 源

概要

1、简介

将 Debian 10  的 apt-get 源更换为 aliyun,以提升国内环境 apt install 的速度。

2、版本信息

Debian 10
apt 1.8.2.1

详细步骤

1、备份原 apt-get 源文件

root@15ee503df884:~# cd /etc/apt
root@15ee503df884:/etc/apt# cp sources.list sources.list.bak

2、清除原 apt 源文件内容

root@15ee503df884:/etc/apt# > sources.list

3、添加 aliyun apt-get 源

root@15ee503df884:~# cd /etc/apt
root@15ee503df884:/etc/apt# echo "deb http://mirrors.aliyun.com/debian  stable main contrib non-free" >> sources.list
root@15ee503df884:/etc/apt# echo "deb http://mirrors.aliyun.com/debian  stable-updates main contrib non-free" >> sources.list

注:这里使用 echo 的方式配置是因为有可能有些系统中并未默认带有 vi 工具(比如 docker 镜像中的 debian 基础镜像中就不带 vi 工具)

4、更新 apt

执行如下命令更新 apt 源

root@15ee503df884:/etc/apt# apt update

验证总结

1、验证配置

执行 cat sources.list 查看文件内容,可以看到配置已经文件。再执行 apt update,如果输出内容中有包含 mirrors.aliyun.com,表示设置已经生效

root@15ee503df884:/etc/apt# cat sources.list
deb http://mirrors.aliyun.com/debian  stable main contrib non-free
deb http://mirrors.aliyun.com/debian  stable-updates main contrib non-free
root@15ee503df884:/etc/apt# apt update
Get:1 http://mirrors.aliyun.com/debian stable InRelease [121 kB]
Get:2 http://mirrors.aliyun.com/debian stable-updates InRelease [49.3 kB]
Get:3 http://mirrors.aliyun.com/debian stable/non-free amd64 Packages [87.7 kB]
Get:4 http://mirrors.aliyun.com/debian stable/main amd64 Packages [7905 kB]
Get:5 http://mirrors.aliyun.com/debian stable/contrib amd64 Packages [51.0 kB]
Get:6 http://mirrors.aliyun.com/debian stable-updates/main amd64 Packages [7380 B]
Fetched 8222 kB in 4s (2157 kB/s)                    
Reading package lists... Done

可以看到,文件内容已经更新,且 apt-get 的源已经切换到了 aliyun。完事收工!

附录

参考阿里云镜像站

https://developer.aliyun.com/mirror/debian

阿里云 debian 镜像支持版本

http://mirrors.aliyun.com/debian/dists/

You may also like...

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注