- 备份下原始文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bakup
- 查看系统把版本
lsb_release -c
显示如下
root@server:/etc/apt# lsb_release -c
Codename: focal
以下是解释 百度出来的那么多方案里面内容不尽相同的原因,因为他们更改apt安装源时用的系统不一样。
我们可以看到新版本的Ubuntu系统代号为focal 同样的我们也可以得到之前任意版本的系统代号:
Ubuntu 12.04(LTS)代号为precise。
Ubuntu 14.04 (LTS)代号为trusty。
Ubuntu 15.04 代号为vivid。
Ubuntu 15.10 代号为wily。
Ubuntu 16.04 (LTS)代号为xenial。
Ubuntu 18.04 (LTS)代号为bionic。
Ubuntu 22.04 (LTS)代号为jammy
- 更改sources.list文件
sudo vi /etc/apt/sources.list
注释掉原来的 将下面的复制到sources.list文件最后 单起一行 保存退出
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal universe
deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe
deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse
4.更新软件列表
sudo apt update
5.更新软件包
sudo apt upgrade
update是更新软件列表,
upgrade 是更新软件