Debian 全版本更换镜像源为阿里云镜像源

【注】系统环境是 Debian 9.2.0 ,其他版本也是可以通用的,只是添加的源不同。

1. 查看当前 Debian 镜像源

less /etc/apt/sources.list

文件部分内容:

# deb http://snapshot.debian.org/archive/debian/20200130T000000Z stretch main
deb http://deb.debian.org/debian stretch main
# deb http://snapshot.debian.org/archive/debian-security/20200130T000000Z stretch/updates main
deb http://security.debian.org/debian-security stretch/updates main
# deb http://snapshot.debian.org/archive/debian/20200130T000000Z stretch-updates main
deb http://deb.debian.org/debian stretch-updates main

...

通过查看地址可以看到默认使用的是 Debian 官方镜像源 http://deb.debian.org/debian

2. 备份当前镜像源

cp /etc/apt/sources.list /etc/apt/sources.list.bak

3. 修改当前镜像源

# 需要 root 权限
sudo vim /etc/apt/sources.list

# 打开文件不要做任何操作,直接输入 ggdG 清空文件,注意 G 是大写
ggdG

清空文件后,然后复制下镜像源(根据自己实际的版本):

  • debian 7.x (wheezy)
deb http://mirrors.aliyun.com/debian/ wheezy main non-free contrib
deb http://mirrors.aliyun.com/debian/ wheezy-proposed-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy-proposed-updates main non-free contrib
  • debian 8.x (jessie)
deb http://mirrors.aliyun.com/debian/ jessie main non-free contrib
deb http://mirrors.aliyun.com/debian/ jessie-proposed-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ jessie main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ jessie-proposed-updates main non-free contrib
  • debian 9.x (stretch)
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib

4. 更新镜像源

sudo apt-get update

控制台部分输出内容:

Ign:1 http://mirrors.aliyun.com/debian stretch InRelease
Get:2 http://mirrors.aliyun.com/debian-security stretch/updates InRelease [53.0 kB]
Get:3 http://mirrors.aliyun.com/debian stretch-updates InRelease [93.6 kB]
Get:4 http://mirrors.aliyun.com/debian stretch-backports InRelease [91.8 kB]
Get:5 http://mirrors.aliyun.com/debian stretch Release [118 kB]
Get:6 http://mirrors.aliyun.com/debian-security stretch/updates/main Sources [332 kB]
Get:7 http://mirrors.aliyun.com/debian-security stretch/updates/main amd64 Packages [650 kB]
Get:8 http://mirrors.aliyun.com/debian stretch-updates/non-free Sources [816 B]
Get:9 http://mirrors.aliyun.com/debian stretch-updates/main Sources [1456 B]
Get:10 http://mirrors.aliyun.com/debian stretch-updates/main amd64 Packages [2596 B]

...

恭喜替换为阿里云镜像源成功。

发表回复

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