每个版本的源都是不同的,
如果源的版本不同就会出现很多的错误,比如gcc缺少依赖项等
首先打开终端输入
lsb_release -a
查看版本的代号和版本
release就是该ubuntu的版本号
codename就是该版本的代号
然后打开源文件:
sudo vim /etc/apt/sources.list
如果显示 vim:没有这个命令 就将vim换成vi或下载vim
sudo apt install vim
按i进入编辑模式
将原来的内容全部删除
将源地址加入进去:
deb http://mirrors.aliyun.com/ubuntu/ codename main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ codename-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ codename-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ codename-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ codename-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ codename-backports main restricted universemultiverse
codename就是课该版本的代号,比如说我的是22.04版本的(jammy),我的源就是
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
ubuntu中复制粘贴的方法:
shift + insert ,ctrl + insert
直接鼠标左键选中要复制的命令,然后在需要粘贴的地方按一下鼠标滚轮即可
之后按esc退出编辑模式
输入:wq
保存并退出
最后更新缓存和升级
sudo apt-get update
sudo apt-get upgrade # 此步骤并非必要,但可以加快以后的下载速度
重启
就完成了