2.修改Ubuntu的aptget源为阿里云源

版权声明:转载请注明! https://blog.csdn.net/linfeng886/article/details/82350541

刚在虚拟机上装了个Ubuntu 18.04版的,然后想着把aptget源改为国内的,这样速度快点
然后就在网上搜,但是大部分都没有说明每个版本有什么不同,后来看到一个介绍的挺详细的文章,然后就成功了,这里做下记录

步骤

一、备份

先把源文件备份了,以防万一
sources.list是包管理工具apt所用的记录软件包仓库位置的配置文件

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

二、查看版本代号

  • 前面修改源出错就出错在这里,因为每个版本的系统版本都不相同
  • 例如 18.04 版本代号是 bionic
  • 用下面命令就可以得到版本的信息,其中的Codename就是版本代号

    lsb_release -a

  • 信息:

    Distributor ID: Ubuntu
    Description: Ubuntu 18.04.1 LTS
    Release: 18.04
    Codename: bionic #版本代号

  • 部分版本代号如下:

版本号 版本代号
18.04 bionic
16.10 yakkety
16.04 xenial
15.10 wily
15.04 vivid
14.10 utopic
14.04 trusty
13.10 saucy
13.04 raring
12.10 quantal
12.04 precise

这个就是我们从网上找的教程,发现在自己系统行不通了的原因了,因为大部分文章都没有说到版本代号,然后发现在他们版本的系统可以,但是你这个版本就不行了

三、打开源文件

  • 先打开文件
  • >sudo vim /etc/apt/sources.list
  • 假如报错,sudo:vim:command not found ,就说明你还没安装vim,你可以先安装 vim
  • >sudo apt-get install vim

四、修改源文件(重要)


  • 把sources.list内的内容全部删除,然后填入以下内容
  • 注意: 我这里是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-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
保存退出

五、更新软件列表

从新的软件源那里更新一下软件列表 用以下命令:

sudo apt-get update

六、更新软件包

本地软件与阿里云的软件版本对比,是否是最新版本 用以下命令:

sudo apt-get upgrade

然后就搞定了

参考文章

猜你喜欢

转载自blog.csdn.net/linfeng886/article/details/82350541