ubuntu20.04更换阿里的软件源

ubuntu20.04更换阿里的软件源,第1张

ubuntu20.04更换阿里的软件源

新安装的ubuntu20.04的软件源是使用的国外的源,因此在使用apt安装软件时速度并不怎么快,建议大家更换为国内的源,这样在使用apt安装软件时速度会有明显的提升的。

ubuntu20.04 apt的配置文件为/etc/apt/sources.list,在更换源之前最好是先备份一下,如果更换不成功还可以恢复回来。

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bac

我们先看一下sources.list文件是什么样子的。

vim /etc/apt/sources.list

将原文件中的源地址注释掉,然后换成阿里的源地址。

sudo sed -i -e 's/deb http:/#deb http:/g' /etc/apt/sources.list

将阿里的源地址添加到sources.list文件中。

执行下面的命令就可以了,注意要切换为root用户。

echo '''deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

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

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

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

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse''' >> /etc/apt/sources.list

查看一下修改完成之后的sources.list文件。

sudo vim /etc/apt/sources.list


验证。

sudo apt update

如果出现下图则说明已经更换成功了。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5714845.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存