Ubuntu更换软件源|apt包管理更换软件源Ubuntu 换源
Excerpt
因为Ubuntu新版默认账户不是root,所以在改sources.list文件时会有权限问题,我们先为root账户创建密码然后输入两遍密码之后进入切换到root用户su root输入密码。
Ubuntu更换软件源|apt包管理更换软件源
一.为root创建密码
因为Ubuntu新版默认账户不是root,所以在改sources.list文件时会有权限问题,我们先为root账户创建密码
1
sudo passwd root
然后输入两遍密码
之后进入切换到root用户
1
su root
输入密码
二.Warning: Changing a readonly file报错解决
先切换至root用户
然后到/etc/apt/目录下1
cd /etc/apt/
改变sources.list权限,使用属主赋予权限
1
chmod u+w sources.list
三.更换软件源
1 | //到/etc/apt/目录下 |
在该界面查找自己Ubuntu版本的软件源
以Ubuntu 20.04为例
1
2
3
4
5
6
7
8
9
10
11
12
13
14 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配置粘贴进去
1 | //使用sudo apt-get update更新软件列表 |
四.清华源软件源更换
到清华源找到对应版本进行更换即可
- 本文链接: http://aurorax.top/2023/11/27/Ubuntu更换软件源/
- 版权声明: 本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。