ubuntu18.04配置镜像源

ubuntu下安装软件,一般都是通过命令sudo apt-get install package来安装想要的软件,这个命令一般都是从一个叫做/etc/apt/source.list文件里找下载地址,而默认的ubuntu也就是新安装的ubuntu,下载软件包都是从ubuntu官网下载,也就是这个source.list包含的是ubuntu官网配置的地址。但这个ubuntu官网不在国内,而在国外,也就是要下载个包,还要从国外网站下,所以这样下载速度自然就慢了。
还好国内也有自己的镜像源,比如清华镜像源,阿里镜像源,这些镜像源包含了咱们想要下的软件包。这样下载软件就不必在国外网下,而直接从国内网站下载,这样下载速度就快了很多。

寻找国内镜像源

这里找的是清华的镜像源
在这里插入图片描述
然后下滑找到ubuntu,点击旁边的问号.
在这里插入图片描述
然后选择相应的ubuntu版本,我用的是18.04版本的,并复制下面字段。
在这里插入图片描述

配置国内镜像

首先拷贝一份/etc/apt/sources.list文件

$ sudo cp -v /etc/apt/sources.list /etc/apt/sources.list.backup

然后编辑sources.list文件

$ sudo gedit /etc/apt/sources.list

在这里插入图片描述
然后全选并删除里面的内容,添加清华镜像源。

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

更新源

配置好后,更新源

$ sudo apt-get update

这样就可以进行sudo apt-get install下载了。

猜你喜欢

转载自blog.csdn.net/qq_41822647/article/details/85122467