Ubuntu换源

在尝试为Ubuntu系统换源时遇到'broken packages'错误,本文提供详细步骤来解决这一问题。首先,查看系统Codename,然后确认阿里云源支持该版本。接着,逐步替换源列表文件中的'bionic'为对应Codename。之后,通过更新源并修复损坏的包,确保安装正确版本。最后执行更新操作以完成源更换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言:按照网上换源的方法出现:Unable to correct problems, you have held broken packages

一、查看系统Codename:

lsb_release -a

或者

cat /etc/apt/sources.list

二、确认阿里源支持:登陆以下网页:http://mirrors.aliyun.com/ubuntu/dists/

三、更换源

sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak
sudo vi /etc/apt/sources.list

以下内容:注意,每一行的bionic应该用第一步查看得到的Codename来代替

deb http://mirrors.aliyun.com/ubuntu/ bionic main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main multiverse restricted universe

四、更新

更新源

sudo apt-get update

修复损坏的包,重新安装正确版本

sudo apt-get -f install

更新软件

 sudo apt-get upgrade
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值