首页 教程 Ubuntu 18.04替换apt为阿里云软件源

Ubuntu 18.04替换apt为阿里云软件源

ASP站长网Ubuntu更改apt源为国内更新源(或者软件源)方法早就有了,内容大同小异,我们应当掌握其规律了,其实每一版内容不同的地方就是版本号(或者官方一点的说:系统代号),所以我们先了解下新版本的系统代号:
 
使用命令:lsb_release -c
 
Ubuntu 18.04更改apt为阿里云软件源
 
得到本系统的系统代号,如下图所示:
 
我们可以看到新版本的Ubuntu系统代号为bionic
 
同样的我们也可以得到之前任意版本的系统代号:
 
Ubuntu 12.04 (LTS)代号为precise。
Ubuntu 14.04 (LTS)代号为trusty。
Ubuntu 15.04 代号为vivid。
Ubuntu 15.10 代号为wily。
Ubuntu 16.04 (LTS)代号为xenial。
 
所以这也就解释了为什么利用搜索引擎搜出来的那么多方案里面内容不尽相同的原因,因为大家更改apt安装源时用的系统不一样。
 
一、首先备份Ubuntu系统的官方源文件
 
1、打开Ubuntu的命令终端,进入源文件 sources.list 所在的目录:
 
Ubuntu 18.04更改apt为阿里云软件源
 
2、然后执行备份命令,执行 sudo cp sources.list sources.list.backup 对源文件内容进行备份,以防万一。
 
cd /etc/apt
sudo cp sources.list sources.list.backup
 
二、修改源文件内容
 
1、阿里源文件内容如下:
 
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这四个)
所以你把内容写成:
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed universe multiverse
 
上面之类的也是可以的,之前我有这个疑惑,所以在这里一并告知和我有一样疑惑的朋友。

关于作者: dawei

【声明】:九江站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

热门文章