Ubuntu 更换 apt 镜像源

版权声明:转载随意,附上转载信息即可 :) https://blog.csdn.net/Al_assad/article/details/80233711

Ubuntu 更换 apt 镜像源


apt 是 Ubuntu 系的包管理工具,一般默认使用 ubuntu 的官方源  http://archive.ubuntu.com/ 在国内下载的速度慢到让人想砸电脑,可以更换为国内的镜像源以提高 apt 的下载速度;

国内镜像源推荐

阿里 OPSX 源: https://opsx.alibaba.com/mirror
网易 163 源: http://mirrors.163.com/
中科大 USTC 源: https://mirrors.ustc.edu.cn/
ubuntu 中国官方源(搜狐): http://mirrors.sohu.com/help/ubuntu.html

※一般在这些镜像源站点,点击需要的镜像源右边的 help 按钮,就会给出该镜像源相关仓库的 URL(甚至包括更改镜像源的操作步骤);

更换镜像源步骤

对于 Ubuntu ,可以通过修改   /etc/apt/sources.list 文件内容来修改 apt 源,以下以更换为 OPSX 的 Ubuntu 镜像源为例;
  • 备份 sources.list 文件
cd /etc/apt/
sudo cp sources.list sources.list.bak
  • 修改 sources.list 文件内容
sudo vim sources.list
将  http://archive.ubuntu.com/  部分更换为获取到的国内镜像源地址,更换后示例内容如下:
eb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  • 更新 apt 本地索引
sudo apt-get update

※至于其他 Linux 发行版更改镜像源,方法也是大同小异的(如 Redhat 系的 yum);


关于 Ubuntu sources.list 文件中关键字的说明

deb   描述一个源软件二进制库
deb-src 描述一个源软件库源代码库
main 完全的自由软件
restricted 不完全的自由软件
universe ubuntu官方不提供支持与补丁,全靠社区支持
muitiverse 非自由软件,完全不提供支持和补丁



猜你喜欢

转载自blog.csdn.net/Al_assad/article/details/80233711