Ubuntu切换数据源

简介: Ubuntu安装完毕之后,默认的源是Ubuntu自己的,但毕竟Ubuntu服务器在国外,我们访问起来会比较慢,可以将软件源切换为国内源,比如:阿里源,清华源,中科大源等等。在这边以清华源为例,其它源也是一样的道理。

Ubuntu安装完毕之后,默认的源是Ubuntu自己的,但毕竟Ubuntu服务器在国外,我们访问起来会比较慢,可以将软件源切换为国内源,比如:阿里源,清华源,中科大源等等。在这边以清华源为例,其它源也是一样的道理。


1 切换源之前先把配置文件备份一份:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak


2 找到清华源官网:

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


一定要选择与自己版本相对应的源,比如当前使用Ubuntu20.04,最好使用此版本的源,否则有可能会有意料不到的问题,良许就吃过这方面的亏。


image.png


网络上也有很多教你换源的帖子,但都是直接给出内容,有可能源与自己的版本不一致,所以最好自己去官网复制。


3.将之前的源全部删除

echo ” > sources.list


4.编辑新源文件

nano sources.list


5.加入新的数据源(清华数据源)

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

6.使用新源替换掉原来的源(一定要加sudo):

sudo vi /etc/apt/sources.list


7.然后更新软件包缓存:

sudo apt update


这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。


8.通常我们会紧跟着再执行命令:

sudo apt-get upgrade


这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,就会提示你更新。


9.备用数据源【阿里】

在下面网站查找最新数据源


https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.b5371b11tio0iu


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-backport
相关文章
|
Ubuntu Linux 网络架构
OpenWRT 的包管理器镜像如何切换成阿里云源?
OpenWRT 的包管理器镜像如何切换成阿里云源?
1661 0
|
19天前
|
Ubuntu 数据安全/隐私保护
ubuntu 系统切换root用户
ubuntu 系统切换root用户
17 0
|
5月前
|
安全 Linux 网络安全
Greenplum【部署 01】CentOS Linux release 7.5 环境单机版详细安装配置步骤+问题解决(含安装包资源)
Greenplum【部署 01】CentOS Linux release 7.5 环境单机版详细安装配置步骤+问题解决(含安装包资源)
51 2
|
弹性计算 Ubuntu Linux
Ubuntu操作系统配置阿里云镜像方法一
Ubuntu操作系统配置阿里云镜像方法一
Ubuntu操作系统配置阿里云镜像方法一
|
弹性计算 Ubuntu Linux
Ubuntu操作系统配置阿里云镜像方法二
Ubuntu操作系统配置阿里云镜像方法二
Ubuntu操作系统配置阿里云镜像方法二
|
缓存 Linux
CentOS7切换阿里镜像并更新
CentOS7切换阿里镜像并更新
696 0
CentOS7切换阿里镜像并更新
|
Ubuntu 开发工具 安全

热门文章

最新文章