概要
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/
该文介绍了如何将Debian10操作系统的apt-get源替换为阿里云镜像源,以加快在国内环境下安装软件包的速度。具体步骤包括备份原源文件,清除内容,添加阿里云源,以及更新apt。通过验证catsources.list和aptupdate的输出,确认阿里云源已成功设置。
5551

被折叠的 条评论
为什么被折叠?



