Ubuntu 20.04系统下更改apt源为阿里源

Ubuntu 20.04.1 LTS已推出,一样的为期5年的服务,感觉不错,安装了一个,但是苦于使用默认源在国内下载太慢,就想着把apt源改为国内源,目前国内比较好的源,有阿里源,清华源,豆瓣源等,下面我以阿里源为例,说下如何修改。

1、备份原文件

修改/etc/apt目录下的sources.list,该文件是包管理工具apt用来记录软件包仓库位置的配置文件。同类型的还有在同一目录下包含.list的各文件。备份命令如下:

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

2、查看版本代号

使用命令:

lsb_release -c

得到本版本系统的系统代号,可以看到版本代号为:focal

每个版本的代号是不一样的,比如:

Ubuntu 15.04 代号为:vivid

Ubuntu 16.04代号为:xenial

Ubuntu 17.04代号为:zesty

Ubuntu 18.04代号为:bionic

Ubuntu 19.04代号为:disco

所以每个版本的修改方式稍微会有点区别。记录下该版本代号,后面我们将会用到。

3、编辑sources.list文件

执行如下命令:

sudo vim /etc/apt/sources.list

如果提示:sudu vim: command not found,说明未安装vim编辑器,使用如下命令安装:

sudo vim apt-get install vim

sources.list里的每个条目都是有格式的:

1. deb http://site.example.com/debian distribution component1 component2 component3
2. deb-src http://site.example.com/debian distribution component1 component2 component3

后面的几个参数是对软件包的分类(ubuntu下是main、restricted、universe、multiverse)。现在我们开始编辑文件,先把原有内容注释,添加如下内容:

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-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports 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

保存,并退出。

4、更新软件列表

执行命令:

sudo apt-get update

5、更新软件包

执行命令:

sudo apt-get upgrade

到此apt源已成功修改为阿里源,可以开始愉快的玩耍了......

往期推荐

Flink中Checkpoint和Savepoint 的 3 个不同点

Flink实现固定时长或消息条数的触发器

Flink方案设计中的4大误区

使用 Broadcast State 的 4 个注意事项

3种Flink State Backend | 你该用哪个?

一文搞定 Flink 异步 I/O

Flink State 使用的4点建议

Flink在开发中的7点建议

转载是一种动力 分享是一种美德, 欢迎关注 大数据与数据仓库公众号, 回复 spark 领取资料

猜你喜欢

转载自blog.csdn.net/yscoder/article/details/110681828