备份
bash
cp -rf /etc/apt/sources.list /etc/apt/sources.list.bak
开始配置
设置镜像地址
阿里云
bash
url=https://mirrors.aliyun.com
清华源
bash
url=https://mirrors.tuna.tsinghua.edu.cn
腾讯云
推荐
shell
url=http://mirrors.cloud.tencent.com
开始修改
shell
sed -i "s@http.*\(com\|org\|cn\)@$url@g" /etc/apt/sources.list
效果
bash
root@Ser6:~# apt update
Hit:1 https://mirrors.aliyun.com/ubuntu jammy InRelease
Hit:2 https://mirrors.aliyun.com/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.aliyun.com/ubuntu jammy-backports InRelease
Get:4 https://mirrors.aliyun.com/ubuntu jammy-security InRelease [110 kB]
Get:5 https://mirrors.aliyun.com/ubuntu jammy-security/main amd64 Packages [631 kB]
Get:6 https://mirrors.aliyun.com/ubuntu jammy-security/main Translation-en [148 kB]
Get:7 https://mirrors.aliyun.com/ubuntu jammy-security/main amd64 c-n-f Metadata [11.0 kB]
Get:8 https://mirrors.aliyun.com/ubuntu jammy-security/restricted amd64 Packages [651 kB]
Get:9 https://mirrors.aliyun.com/ubuntu jammy-security/restricted Translation-en [104 kB]
Get:10 https://mirrors.aliyun.com/ubuntu jammy-security/restricted amd64 c-n-f Metadata [532 B]
Get:11 https://mirrors.aliyun.com/ubuntu jammy-security/universe amd64 Packages [756 kB]
Get:12 https://mirrors.aliyun.com/ubuntu jammy-security/universe Translation-en [136 kB]
Get:13 https://mirrors.aliyun.com/ubuntu jammy-security/universe amd64 c-n-f Metadata [15.9 kB]
Get:14 https://mirrors.aliyun.com/ubuntu jammy-security/multiverse amd64 Packages [36.5 kB]
Get:15 https://mirrors.aliyun.com/ubuntu jammy-security/multiverse Translation-en [7060 B]
Get:16 https://mirrors.aliyun.com/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [260 B]
Fetched 2609 kB in 1s (1952 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
65 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@Ser6:~#