• 更新ubuntu的源


    什么是Ubuntu的软件源?

    我们在使用Debian或者Ubuntu的apt-get工具来安装需要的软件时,其实就是从服务器获取需要安装的软件并把它安装在本地计算机的过程。所谓的软件源,就是我们获取软件的来源,它是定义在/etc/apt/sources.list文件里的。

     官方的默认源是来自美国的us.archive.ubuntu.com和security.ubuntu.com。那么我们怎么样换成速度更快的国内源呢?很简单,把/etc/apt/sources.list文件复制备份一下,然后把原来的内容修改成国内源的网址即可。以下步骤说明以阿里云的源为例:

    1、复制备份原来的配置文件

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

    2、替换源

    阿里云源的文件

    deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse 
      deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse 
      deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse 
      deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse 
      ##测试版源 
      deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse 
      # 源码 
      deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse 
      deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse 
      deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse 
      deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse 
      ##测试版源 
      deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse 
      # Canonical 合作伙伴和附加 
      deb http://archive.canonical.com/ubuntu/ xenial partner 
      deb http://extras.ubuntu.com/ubuntu/ xenial main

    也可以替换为网易的源

    deb http://mirrors.163.com/ubuntu/ zesty main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ zesty-security main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ zesty-updates main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ zesty-proposed main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ zesty-backports main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ zesty main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ zesty-security main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ zesty-updates main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ zesty-proposed main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ zesty-backports main restricted universe multiverse

    执行apt-get update,apt-get upgrade

    如果是添加的网易源,可能会发现会报错,apt-get: Could not resolve 'mirrors.163.com’的错误,这种原因其实是因为还缺少一个步骤,就是将添加的网址和IP进行映射,修改/etc/目录下的host文件。

     通过ip.chinaz.com进行查询网址“mirrors.163.com”,对应的ip地址如下所示,然后将其添加到hosts文件里。

    123.58.190.228     mirrors.163.com
    123.58.190.236     mirrors.163.com

    再执行apt-get update,apt-get upgrade就好了

  • 相关阅读:
    java基础面试题:说说&和&&的区别
    java基础面试题:java中有没有goto? 在JAVA中如何跳出当前的多重嵌套循环?
    Java基础面试操作题: 获取 1-20 之间的随机数,共计 20 个,要求不能重复 获取 1-20 之间的随机数,共计 10 个,要求不能重
    Intellij设置Eclipse 快捷键
    Intellij 安装sonarlint
    Intellij 关闭参数提示
    Linux中Firefox——Firebug插件安装及使用
    Linux中Firefox——Httpfox插件安装及使用
    OpenCV——Haar-like特征
    Python学习笔记6(列表生成式)
  • 原文地址:https://www.cnblogs.com/wujing-hubei/p/8868019.html
Copyright © 2020-2023  润新知