ubuntu18.04更换默认下载源为国内清华源、阿里源

为啥要更换国内源

首先,当然是为了更快的下载速度,因为国外源服务器距离我们太远,光DNS寻址以及网络节点的转发都要浪费很长时间,使用国内源可以大大加快下载速度;其次,没办法啊,因为编程语言就是外国人发明的,现在国内使用的大量第三方包几乎都来自国外,不废话了,来看看怎么更换国内源。

apt apt-get简介

这两个命令是ubuntu上自带的包管理软件,可以搜索、下载以及安装包,就是ubuntu系统的软件管理的一个命令,好像你在windows通过电脑管家下载、卸载管理软件一样,我们用windows系统最多,对linux系统不熟,学习的时候多多把windows联想在一起,找出两者的异同点,然后更容易学习linux,另外ubuntu只是linux的一个发行版,还有其它许多发行版,有兴趣的可以去了解一下,我个人比较喜欢使用ubuntu。

更换清华源

我们知道,linux里一且皆是文件,不管你是什么东西,都可以用文件来描述,这就是一个妥妥的大型文件系统啊!所以,我们的下载源配置也是通过更改或者新建一个文件,在里面写入我们的配置即可,系统会自动寻找此文件并获取里面的源地址。

首先,在shell中cd到/etc/apt/目录下,然后使用命令ls查看有哪些文件,其中sources.list就是我们要修改的文件,使用命令vim sources.list编辑此文件,里面默认配置的是国外源,把里面的内容全部删掉即可,vim怎么删除自行百度。然后把下面的清华源加入其中:

# 默认注释了源码镜像以提高 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

在这里插入图片描述

需要注意的是,我这里是ubuntu18.04版本的配置,不同的版本可能有所不同,对于其它版本的小伙伴,可以通过下面的链接到清华源的使用帮助,自己选择相应的版本进行配置;Ubuntu清华镜像站使用帮助

更换阿里源

  • Ubuntu 14.04.5 LTS配置如下:
deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

## Not recommended
# deb https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
  • ubuntu 16.04 配置如下:
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

  • 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

  • ubuntu 20.04(focal) 配置如下:
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

需要注意的是,请一定要看好自己的ubuntu是什么版本的,可以用命令unmae -a或者lsb_release -a查看对用的版本,也可以参考下面的链接,是阿里云官方文档,当然这些源也不是一成不变的,有时候失效了需要到官方文档查看最新的配置,阿里源官方文档

其它源

还有其它的源如中科大源,华为源,豆瓣源等等,因为每个大公司为了自己开发方便,都会构建自己的源来供自己使用,有的公司比较慷慨就免费提供给我们使用。

更新缓存

更换完源之后,需要使用命令sudo apt-get update或者sudo apt update来更新一下缓存,这样系统才会清楚掉原来缓存的源,更换新的源地址,下载源才会生效。

参考文章:

阿里云:

  • https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11kix0e9

清华源:

  • https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

其它:

  • 下载地址: https://mirrors.aliyun.com/ubuntu/
  • 官方主页: http://www.ubuntu.com/
  • 邮件列表: http://www.ubuntu.com/support/community/mailinglists
  • 论坛: http://ubuntuforums.org/
  • 中文论坛: http://forum.ubuntu.org.cn/
  • Wiki: https://wiki.ubuntu.com/
  • 帮助: https://help.ubuntu.com/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值