切换root用户
su root
不会root请移步 https://www.wenlk.com/781.html这篇教程
查看系统版本等信息
lsb_release -a
release为ubuntu的版本 codename为版本的代号
备份一下你的版本文件(建议备份),
cd /etc/apt/ cp sources.list sources.list.bak
恢复备份命令为(换源失败后可救命)
cp source.list.bak sources.listd
打开文件修改源,如没有vim用vi代替即可或者输入命令安装(sudo apt install vim)
sudo vim /etc/apt/sources.list
方法二,删除文件新建一个(好处:省时间)
rm -rf sources.list
vi source.list
将TODO替换成codename后的版本代码
示例: 我的是22.04 版本( jammy),那么我的源就是如下配置
将下方代码中TODO替换为你的"codename"后 按"i"键 ctrl+shif+v粘贴下方代码
deb http://mirrors.aliyun.com/ubuntu/ TODO main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ TODO main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ TODO-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ TODO-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ TODO-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ TODO-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ TODO-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ TODO-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ TODO-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ TODO-backports main restricted universemultiverse
之后按esc退出编辑模式
输入:wq
保存并退出
随后更新缓存后重启即可
sudo apt-get update
sudo apt-get upgrade
reboot