Linux(Ubuntu 18)之更改apt源为阿里云源(二)

Ubuntu 18 更换源

1. 复制源文件备份,以防万一

sources.list是包管理工具apt所用的记录软件包仓库位置的配置文件,同样类型的还有位于 同目录下sources.list.d文件下的各种.list后缀的各文件。

我们要修改的文件是sources.list,它在目录/etc/apt/下,

命令如下:

1、进入对应目录

cd /etc/apt/

2、先进行文件的拷贝,以访万一

sudo cp sources.list sources.list.bak

2、查看版本信息

Ubuntu18.04版之前的任一版更改apt源为国内源方法早就有了,内容大同小异,主要就是不同版本的系统代码不同导致增加的东西不同,所以我们需要查看一下版本的信息,然后直接套规律即可

使用如下命令:

lsb_release -c

得到本系统的系统代号,如下图所示:
在这里插入图片描述
我们可以看到新版本的Ubuntu系统代号为bionic

Ubuntu不同版本的系统代号如下:

Ubuntu 12.04 (LTS)代号为precise。

Ubuntu 14.04 (LTS)代号为trusty。

Ubuntu 15.04 代号为vivid。

Ubuntu 15.10 代号为wily。

Ubuntu 16.04 (LTS)代号为xenial。

3、更改内容

1、编辑该文件

sudo vim source.list

2、若没有vim,安装即可

sudo apt-get install vim 

3.将原有的内容注释掉,添加以下内容(或者你把里面内容修改成下面的就可以,但是不能有除了以下内容的有效内容)

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-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports 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

值得注意的是sources.list文件的条目都是有格式的(通过上面的内容大家也看的出来),一般有如下形式

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

有个参数是系统的代码,后面几个参数是对软件包的分类(Ubuntu下是main, restricted,universe ,multiverse这四个)

猜你喜欢

转载自blog.csdn.net/weixin_42272869/article/details/112970210
今日推荐