前言
当Ubuntu原自带的源在下载安装软件包出错时,一般需采用换源来解决。
第一步,将原配置文件备份,以免后续需要恢复。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
第二步打开配置文件,更改源
sudo vim /etc/apt/sources. List
根据自己系统的版本,来找相应的源,本人安装的是Ubuntu20.04版本,用了清华源(连接),
附代码(20.04):
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiversedeb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse# 预发布软件源,不建议启用# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
将sources.list里面原有的代码先全部删除,然后ctrl+shift+v,粘贴新源,然后wq保存并退出。
第三步,更新源
分别执行以下命令
sudo apt-get updatesudo apt-get upgrade
更新完成后,再次尝试安装软件。
来源地址:https://blog.csdn.net/m0_63387201/article/details/129830743