• Ubuntu的软件源问题总结


    今天晚上用官方源打算安装东西的时候发现速度偏慢,哎,这么不靠谱,这不是逼我投向别人的怀抱嘛。开了N个网页,总算搞清楚源是肿么回事了,果断码个总结!

     

    一、软件源的描述

    软件源就是一个应用程序安装库,很多很多的应用软件都在这个库里面。他可以是网络服务器,是光盘,甚至是硬盘上的一个目录。所以说要安装好软件且方便快捷,那首先得找到一个好的源,然后修改源文件更新下即可。

     

    二、怎么修改源

    源文件具体目录:/etc/apt/sources.list

    我的Ubuntu版本是11.10,刚安装Ubuntu后sources.list文件内容如下:

     1 #deb cdrom:[Ubuntu 11.10 _Oneiric Ocelot_ - Release i386 (20111012)]/ oneiric main restricted
     2 
     3 # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
     4 # newer versions of the distribution.
     5 deb http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
     6 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
     7 
     8 ## Major bug fix updates produced after the final release of the
     9 ## distribution.
    10 deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
    11 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
    12 
    13 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    14 ## team. Also, please note that software in universe WILL NOT receive any
    15 ## review or updates from the Ubuntu security team.
    16 deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe
    17 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric universe
    18 deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates universe
    19 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates universe
    20 
    21 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    22 ## team, and may not be under a free licence. Please satisfy yourself as to
    23 ## your rights to use the software. Also, please note that software in
    24 ## multiverse WILL NOT receive any review or updates from the Ubuntu
    25 ## security team.
    26 deb http://us.archive.ubuntu.com/ubuntu/ oneiric multiverse
    27 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric multiverse
    28 deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates multiverse
    29 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates multiverse
    30 
    31 ## N.B. software from this repository may not have been tested as
    32 ## extensively as that contained in the main release, although it includes
    33 ## newer versions of some applications which may provide useful features.
    34 ## Also, please note that software in backports WILL NOT receive any review
    35 ## or updates from the Ubuntu security team.
    36 deb http://us.archive.ubuntu.com/ubuntu/ oneiric-backports main restricted universe multiverse
    37 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-backports main restricted universe multiverse
    38 
    39 deb http://security.ubuntu.com/ubuntu oneiric-security main restricted
    40 deb-src http://security.ubuntu.com/ubuntu oneiric-security main restricted
    41 deb http://security.ubuntu.com/ubuntu oneiric-security universe
    42 deb-src http://security.ubuntu.com/ubuntu oneiric-security universe
    43 deb http://security.ubuntu.com/ubuntu oneiric-security multiverse
    44 deb-src http://security.ubuntu.com/ubuntu oneiric-security multiverse
    45 
    46 ## Uncomment the following two lines to add software from Canonical's
    47 ## 'partner' repository.
    48 ## This software is not part of Ubuntu, but is offered by Canonical and the
    49 ## respective vendors as a service to Ubuntu users.
    50 # deb http://archive.canonical.com/ubuntu oneiric partner
    51 # deb-src http://archive.canonical.com/ubuntu oneiric partner
    52 
    53 ## This software is not part of Ubuntu, but is offered by third-party
    54 ## developers who want to ship their latest software.
    55 deb http://extras.ubuntu.com/ubuntu oneiric main
    56 deb-src http://extras.ubuntu.com/ubuntu oneiric main

    从文件内容我们可以看出官方源服务器位于美国,既然要找个速度快的,显然得换个国内的源嘛。由于国内源众多,据说163源蛮好,所以我选择了163的源;不过据说骨头源也蛮不错,不过我已经选择了163了,要专一啊!!反正好的源很多,看自己是电信的还是网通的,找个合适自己的最好!

    OK,把原来的文件sources.list备份到sources.list-origin,我现在的sources.list的内容更换如下:

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

    OK,接下来简要分析下sources.list的内容的意思,地址是http://mirrors.163.com/ubuntu/这个呢就是163的ubuntu源的服务器目录,这个目录下的内容我们还是要了解一下的,等会分析。然后有一个字符串引起我们的注意,而且至关重要,没错,就是:oneiric,这是Ubuntu 11.10的名字,具体有什么用还是等会带来讲解。

    好的,接下来分析一下这个163服务器,进入这个服务器后(http://mirrors.163.com/ubuntu/),我们进入dists目录,可以看到此时目录下内容为:

    ../
    hardy/                                             14-Oct-2011 15:23                   -
    hardy-backports/                                   15-Jul-2012 14:54                   -
    hardy-proposed/                                    21-Jul-2012 15:30                   -
    hardy-security/                                    13-Jun-2012 15:09                   -
    hardy-updates/                                     21-Jul-2012 15:30                   -
    lucid/                                             14-Oct-2011 15:23                   -
    lucid-backports/                                   18-Jul-2012 15:24                   -
    lucid-proposed/                                    30-Jul-2012 14:57                   -
    lucid-security/                                    18-Jul-2012 15:23                   -
    lucid-updates/                                     22-Jul-2012 15:13                   -
    maverick/                                          14-Oct-2011 15:23                   -
    maverick-backports/                                04-Apr-2012 14:59                   -
    maverick-proposed/                                 04-Apr-2012 14:59                   -
    maverick-security/                                 24-Mar-2012 14:57                   -
    maverick-updates/                                  24-Mar-2012 14:57                   -
    natty/                                             14-Oct-2011 15:23                   -
    natty-backports/                                   03-May-2012 15:32                   -
    natty-proposed/                                    31-Jul-2012 14:37                   -
    natty-security/                                    18-Jul-2012 15:23                   -
    natty-updates/                                     19-Jul-2012 15:18                   -
    oneiric/                                           14-Oct-2011 15:22                   -
    oneiric-backports/                                 04-Apr-2012 14:58                   -
    oneiric-proposed/                                  01-Aug-2012 15:21                   -
    oneiric-security/                                  18-Jul-2012 15:23                   -
    oneiric-updates/                                   21-Jul-2012 15:29                   -
    precise/                                           26-Apr-2012 14:30                   -
    precise-backports/                                 16-Jul-2012 15:00                   -
    precise-proposed/                                  01-Aug-2012 21:14                   -
    precise-security/                                  01-Aug-2012 21:14                   -
    precise-updates/                                   01-Aug-2012 21:14                   -
    quantal/                                           01-Aug-2012 21:14                   -
    quantal-backports/                                 27-Apr-2012 15:32                   -
    quantal-proposed/                                  01-Aug-2012 21:14                   -
    quantal-security/                                  27-Apr-2012 15:32                   -
    quantal-updates/                                   27-Apr-2012 15:32                   -

    那这个内容对我们有什么用呢?我们可以看到里面有hardy,lucid,oneiric等,这些呢,就是Ubuntu版本代号。每个Ubuntu版本都是有版本名的,不清楚可以进入百科查看hardy对应的是Ubuntu 8.04,而lucid对应的是Ubuntu 10.04。不同版本要求的的源文件的内容也是不同的,所以需要看清楚。

    在此目录中我们可以看到我们需要的版本11.10对应的源:oneiric,有了这个我们才能用163的源。

    那假设我现在的Ubuntu版本是11.04,那我怎么修改sources.list的内容呢?很简单,首先我们知道11.04的英文名是natty,我们从这个服务器可以看到有natty的目录,那我们只需要把我刚更新的163的源文件中的oneiric改为natty,保存就可以了,方便吧!如果没有natty,那么显然修改了也找不到的,所以需要看清楚有没对应自己Ubuntu版本的源。

    三、修改源后操作

    经过上面的操作,现在已经换好源了,肯定要让它生效吧,按下面的步骤来即可:

    1)sudo apt-get update #这一步是更新你的源列表,换源后必须执行

    2)sudo apt-get dist-upgrade #这一步是更新软件

    OK,换源完成,要安装什么东西输入"sudo apt-get install [软件名] "即可。而且速度蛮快!

    本文完。

  • 相关阅读:
    工厂模式
    dubbo
    WebSocket WebService
    消息中间
    原型模式
    ApiPost Apifox
    Future 的使用与源码解析
    JUC 线程池的使用与源码解析
    ReentrantLock 源码解析
    CountDownLatch 的使用与源码解析
  • 原文地址:https://www.cnblogs.com/morphling/p/2619201.html
Copyright © 2020-2023  润新知