Ubuntu更换软件源|apt包管理更换软件源

Ubuntu更换软件源|apt包管理更换软件源

一.为root创建密码

  • 因为Ubuntu新版默认账户不是root,所以在改sources.list文件时会有权限问题,我们先为root账户创建密码

    sudo passwd root
    

    然后输入两遍密码

  • 之后进入切换到root用户

    su root
    

    输入密码

二.Warning: Changing a readonly file报错解决

  • 先切换至root用户
    然后到/etc/apt/目录下

    cd /etc/apt/
    

    改变sources.list权限,使用属主赋予权限

    chmod u+w sources.list
    

三.更换软件源

//到/etc/apt/目录下
cd /etc/apt/
//对sources.list文件做一个备份
cp sources.list sources.list

首先到阿里云打开Ubuntu镜像界面

在这里插入图片描述

在该界面查找自己Ubuntu版本的软件源

在这里插入图片描述

以Ubuntu 20.04为例

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

使用vi或vim打开sources.list

按下esc,按下gg,再按dG,全部删除

之后将aliyun配置粘贴进去

在这里插入图片描述

//使用sudo apt-get update更新软件列表
sudo apt-get update
//使用sudo apt-get upgrade更新软件
sudo apt-get upgrade

四.清华源软件源更换

清华源找到对应版本进行更换即可

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值