ubuntu换源转载
# 0. 一键复制
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb 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 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" | sudo tee /etc/apt/sources.list
sudo apt-get update
1
2
3
4
5
6
7
2
3
4
5
6
7
# 1.备份原来的源,将以前的源备份一下,以防以后可以用的。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 2.打开/etc/apt/sources.list文件,在前面添加如下条目,并保存。
sudo vim /etc/apt/sources.list
(
可将vim更换为自己熟悉的编辑器)
# 3.换源(任选其一)
- 添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
- 添加清华源
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 multiverse
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 4.更新
- 更新源
sudo apt-get update
- 如出现依赖问题,解决方式如下:
sudo apt-get -f install
- 更新软件:
sudo apt-get upgrade
编辑 (opens new window)
上次更新: 2024/11/17, 13:04:13
- 02
- containerd高版本换源,containerd换源无效问题11-07
- 03
- apt-get使用代理11-05