新安装的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
如果出现下图则说明已经更换成功了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)