Ubuntu更改apt-get国内镜像源
Ubuntu更改apt-get国内镜像源
介绍
很多刚安装ubuntu系统的小伙伴们可能会遇到在使用Ubuntu包管理工具apt-get 的时候,安装很多软件包下载速度巨慢的问题,其实问题出在了包管理器的镜像源上,默认情况下apt使用国外http://ports.ubuntu.com/ 的镜像,通过vim /etc/apt/sources.list 可查看本机使用的镜像源是否为国外的镜像源,如果是,则需要替换所有国外镜像源为国内镜像源。阿里云镜像站源提供了多个系统以及各个包管理仓库的镜像,镜像地址。这里以阿里云提供的Ubuntu镜像为例。
配置方法
- 查看当前Ubuntu版本
root@rock64:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic Distributor
ID 是ubuntu
Description 18年4月发布的稳定版本,LTS是Long Term
Release 为发行日期或者是发行版本号
Codename 为ubuntu的代号名称
- 查找本机对应Ubuntu版本的镜像
点开 阿里云官方镜像站 进入Ubuntu系统镜像,找到本机对应的Ubuntu系统版本的配置,以本机Ubuntu 18.04的版本为例。
ubuntu 18.04(bionic) 配置如下:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src 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-backports main restricted universe multiverse
- 替换本机的国外镜像源
使用vim或任意你喜欢的编辑器替换sources.list文件中的所有内容为上面的镜像源。vim /etc/apt/sources.list