软件源(Software Sources)

时间:2023-03-09 08:54:53
软件源(Software Sources)

写在前面:浏览了很多国内外的网站,看了很多关于软件源(Software Sources)设置的文章,发现有很多文章中对软件源的设置存在误解,为了让新人能顺利进入Ubuntu的大家庭,特地作此文,详细地介绍下软件源的设置。

1、软件源(Software Sources)是什么?

在Ubuntu中,软件源是指一个由可以获得软件的地址组成的集合,这个地址可以是网站、光盘,或者是硬盘上的一个目录。软件源上有“软件仓库”, 软件 仓库中存储着各种各样的软件。当你需要用到一个软件的时候,就可以通过工具(新立得synaptic 、 apt-get 或者 aptitude 等),自动地下载并自动地安装。

2、软件源(Software Sources)设置好了,我可以获得哪些便利?

日常的软件安装或者更新都是采用从软件源获取软件包的方式。设置好软件源可以让你及时获取重要的安全更新,解决安全隐患;或者修复已知的问题,让使用更顺手。设置好软件源同样可以加快以上操作的速度,节约你宝贵的时间。

3、我是新手,我不会设置,有简单的图形化界面的设置方法吗?

Ubuntu的系统(System)-系统管理(Administration)菜单里提供了图形化界面的软件源设置(Software Sources)程序,不过提醒一下大家,只使用这个是不够的!(具体设置方法请继续往下看)

4、正确的设置方法!

在开始修改设置之前,先备份一下原来的设置。这一步看似多余,其实是一种很好的习惯,有利于配置错误时的恢复。备份方法是:按Alt+F2,然后输 入 gksu cp /etc/apt/sources.list /etc/apt/sources.list-backup。回车后输入你的密码。

然后打开设置程序:系统(System)-系统管理(Administration)-软件源设置(Software Sources)。在第一个标签页上,单击“下载自(Download From)”右边的菜单,选择“其他…(Others…)”。然后在弹出的窗口中单击“选择最佳服务器(Select Best Server)”。下面系统会自动ping官方服务器列表中的服务器,并选择最快的!

再按Alt+F2打开“运行程序(Run Application)”,输入 gksu gedit /etc/apt/sources.list。回车后如果有提示输入密码,输入你的密码。把光标调到文件的最后。

(1)电信用户加入下面的内容:

deb http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn hardy main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy restricted main universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://archive.ubuntu.com/ubuntu/ hardy restricted main universe
deb http://archive.ubuntu.com/ubuntu/ hardy universe
deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates universe #Added by software-properties
deb http://security.ubuntu.com/ubuntu hardy-security main restricted
deb-src http://security.ubuntu.com/ubuntu hardy-security restricted main universe
deb http://security.ubuntu.com/ubuntu hardy-security universe

(2)网通/教育网用户加入下面的内容:

deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-backports main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn hardy main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy restricted main universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy universe
deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb http://archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://archive.ubuntu.com/ubuntu/ hardy restricted main universe
deb http://archive.ubuntu.com/ubuntu/ hardy universe
deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates universe #Added by software-properties
deb http://security.ubuntu.com/ubuntu hardy-security main restricted
deb-src http://security.ubuntu.com/ubuntu hardy-security restricted main universe
deb http://security.ubuntu.com/ubuntu hardy-security universe

然后按Ctrl+S保存文档,关掉这个窗口。

5、为什么我要设置这么多国外源?

Ubuntu的项目是由世界各地的爱好者共同维护的,因此服务器端文件的更新很难做到同步。由于Ubuntu的主服务器在欧洲,项目小组在挪威国, 而英语是Ubuntu用户中使用最广的语言,因此最新的更新版本很快被发布到Ubuntu的欧洲主源和美国源。同时国内的Ubuntu更新源经常存在软件包缺失的问题,因此推荐大家设置欧洲和美国的官方源。

6、源越多速度越快吗?

很不幸,Ubuntu的软件管理程序没有自动判断最快源的功能。因此无论你设置了多少源,Ubuntu只按照源列表的顺序,找到第一个提供相应软件包下载的源并连接下载。因此我们在设置的时候 让Ubuntu先自动找最快的源,然后把可能作为补充的源加在后面。相反地,设置的源过多,反而会降低更新 (apt-get update)的速度。

附录:官方源列表中没有的常用软件源列表(可以自己试试哪个更快,但是不要去掉国外源)

Ubuntu.cn99.com更新服务器(江苏省常州市电信,推荐电信用户使用):

deb http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn/ hardy main restricted universe multiverse

Mirror.lupaworld.com更新服务器(浙江省杭州市双线服务器):

deb http://mirror.lupaworld.com/ubuntu hardy main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu hardy-security main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu hardy-updates main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu hardy-backports main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu hardy-proposed main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu hardy main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu hardy-security main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu hardy-updates main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu hardy-backports main restricted universe multiverse
deb-src http://mirror.lupaworld.com/ubuntu hardy-proposed main restricted universe multiverse

厦门大学更新服务器(教育网服务器):

deb ftp://ubuntu.realss.cn/ubuntu/ hardy main restricted universe multiverse
deb ftp://ubuntu.realss.cn/ubuntu/ hardy-backports restricted universe multiverse
deb ftp://ubuntu.realss.cn/ubuntu/ hardy-proposed main restricted universe multiverse
deb ftp://ubuntu.realss.cn/ubuntu/ hardy-security main restricted universe multiverse
deb ftp://ubuntu.realss.cn/ubuntu/ hardy-updates main restricted universe multiverse
deb-src ftp://ubuntu.realss.cn/ubuntu/ hardy main restricted universe multiverse
deb-src ftp://ubuntu.realss.cn/ubuntu/ hardy-backports main restricted universe multiverse
deb-src ftp://ubuntu.realss.cn/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src ftp://ubuntu.realss.cn/ubuntu/ hardy-security main restricted universe multiverse
deb-src ftp://ubuntu.realss.cn/ubuntu/ hardy-updates main restricted universe multiverse

成都市 电子科技大学更新服务器(教育网,推荐校园网和网通用户使用):

deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy main multiverse restricted universe
deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy-backports main multiverse restricted universe
deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy-proposed main multiverse restricted universe
deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy-security main multiverse restricted universe
deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy-updates main multiverse restricted universe
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy main multiverse restricted universe
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy-backports main multiverse restricted universe
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy-security main multiverse restricted universe
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy-updates main multiverse restricted universe

== 如果无法解析uestc.edu.cn域名,请使用以下地址 ==

deb http://ubuntu.dormforce.net/ubuntu/ hardy main multiverse restricted universe
deb http://ubuntu.dormforce.net/ubuntu/ hardy-backports main multiverse restricted universe
deb http://ubuntu.dormforce.net/ubuntu/ hardy-proposed main multiverse restricted universe
deb http://ubuntu.dormforce.net/ubuntu/ hardy-security main multiverse restricted universe
deb http://ubuntu.dormforce.net/ubuntu/ hardy-updates main multiverse restricted universe
deb-src http://ubuntu.dormforce.net/ubuntu/ hardy main multiverse restricted universe
deb-src http://ubuntu.dormforce.net/ubuntu/ hardy-backports main multiverse restricted universe
deb-src http://ubuntu.dormforce.net/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://ubuntu.dormforce.net/ubuntu/ hardy-security main multiverse restricted universe
deb-src http://ubuntu.dormforce.net/ubuntu/ hardy-updates main multiverse restricted universe

上海市上海交通大学更新服务器(教育网,推荐校园网和网通用户使用):

deb http://ftp.sjtu.edu.cn/ubuntu/ hardy main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu/ hardy-backports main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu/ hardy-proposed main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu/ hardy-security main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu/ hardy-updates main multiverse restricted universe
deb-src http://ftp.sjtu.edu.cn/ubuntu/ hardy main multiverse restricted universe
deb-src http://ftp.sjtu.edu.cn/ubuntu/ hardy-backports main multiverse restricted universe
deb-src http://ftp.sjtu.edu.cn/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://ftp.sjtu.edu.cn/ubuntu/ hardy-security main multiverse restricted universe
deb-src http://ftp.sjtu.edu.cn/ubuntu/ hardy-updates main multiverse restricted universe

中国科学技术大学更新服务器(教育网,推荐校园网和网通用户使用):

deb http://debian.ustc.edu.cn/ubuntu/ hardy main multiverse restricted universe
deb http://debian.ustc.edu.cn/ubuntu/ hardy-backports main multiverse restricted universe
deb http://debian.ustc.edu.cn/ubuntu/ hardy-proposed main multiverse restricted universe
deb http://debian.ustc.edu.cn/ubuntu/ hardy-security main multiverse restricted universe
deb http://debian.ustc.edu.cn/ubuntu/ hardy-updates main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ hardy main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ hardy-backports main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ hardy-security main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/ubuntu/ hardy-updates main multiverse restricted universe

北京市清华大学更新服务器(教育网,推荐校园网和网通用户使用):

deb http://mirror9.net9.org/ubuntu/ hardy main multiverse restricted universe
deb http://mirror9.net9.org/ubuntu/ hardy-backports main multiverse restricted universe
deb http://mirror9.net9.org/ubuntu/ hardy-proposed main multiverse restricted universe
deb http://mirror9.net9.org/ubuntu/ hardy-security main multiverse restricted universe
deb http://mirror9.net9.org/ubuntu/ hardy-updates main multiverse restricted universe
deb-src http://mirror9.net9.org/ubuntu/ hardy main multiverse restricted universe
deb-src http://mirror9.net9.org/ubuntu/ hardy-backports main multiverse restricted universe
deb-src http://mirror9.net9.org/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://mirror9.net9.org/ubuntu/ hardy-security main multiverse restricted universe
deb-src http://mirror9.net9.org/ubuntu/ hardy-updates main multiverse restricted universe

沈阳市东北大学更新服务器(教育网,推荐校园网和网通用户使用):

deb ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy main multiverse restricted universe
deb ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy-backports main multiverse restricted universe
deb ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy-proposed main multiverse restricted universe
deb ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy-security main multiverse restricted universe
deb ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy-updates main multiverse restricted universe
deb-src ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy main multiverse restricted universe
deb-src ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy-backports main multiverse restricted universe
deb-src ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy-security main multiverse restricted universe
deb-src ftp://ftp.neu.edu.cn/mirror/archive.ubuntu.com/ubuntu/ hardy-updates main multiverse restricted universe

中国* *大学更新服务器(推荐网通用户使用,电信PING平均响应速度41MS。强烈推荐此源,比较完整,较少出现同步问题):

deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-backports main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ hardy-proposed main restricted universe multiverse

Mirror.vmmatrix.net更新服务器(上海市电信,推荐电信网通用户使用):

deb http://mirror.vmmatrix.net/ubuntu/ hardy main restricted universe multiverse
deb-src http://mirror.vmmatrix.net/ubuntu/ hardy main restricted universe multiverse
deb http://mirror.vmmatrix.net/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://mirror.vmmatrix.net/ubuntu/ hardy-updates main restricted universe multiverse
deb http://mirror.vmmatrix.net/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://mirror.vmmatrix.net/ubuntu/ hardy-backports main restricted universe multiverse
deb http://mirror.vmmatrix.net/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://mirror.vmmatrix.net/ubuntu/ hardy-security main restricted universe multiverse
deb http://mirror.vmmatrix.net/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://mirror.vmmatrix.net/ubuntu/ hardy-proposed main restricted universe multiverse

ubuntu.cnsite.org更新服务器(福建省福州市 电信):

deb http://ubuntu.cnsite.org/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.cnsite.org/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.cnsite.org/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.cnsite.org/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.cnsite.org/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.cnsite.org/ubuntu/ hardy-backports main restricted universe multiverse
deb http://ubuntu.cnsite.org/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.cnsite.org/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.cnsite.org/ubuntu/ hardy-proposed main multiverse restricted universe
deb-src http://ubuntu.cnsite.org/ubuntu/ hardy-proposed main restricted universe multiverse

7、非官方源出错:缺少公钥

 当我们在/etc/apt/sources.list中加入非Ubuntu官方源来安装、更新部分软件时,sudo apt-get update会有错误提示

  下面以我使用的ibus非官方源作为示例,错误提示如下:

  W: GPG error: http://ppa.launchpad.net jaunty Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 21C022AA985E0E11

  W: You may want to run apt-get update to correct these problems

  也就是这个非官方源是不可信任的,解决办法是导入该源的公钥。

  因为平时我们是使用sudo来管理系统的,所以有些地方要注意,不然很容易出现错误。

  先把这个源的公钥从公钥服务器导入到当前用户的公钥库

  $gpg -–keyserver keyserver.ubuntu.com –-recv-keys 21C022AA985E0E11

  此处没有必要用sudo来运行,把公钥导入当前用户即可,使用了反而有可能提示错误

  gpg: WARNING: unsafe ownership on configuration file `/home/username/.gnupg/gpg.conf’

  gpg: external program calls are disabled due to unsafe options file permissions

  gpg: keyserver communications error: general error

  gpg: keyserver receive failed: general error

  因为这样会导致gpg.conf的所有者与运行程序的用户不一致,当然如果你在root用户下运行则不存在这个问题,因为公钥导入到了root用户的密钥库。

  公钥导入成功后会有如些提示:

  gpg: requesting key 985E0E11 from hkp server wwwkeys.eu.pgp.net

  gpg: key 985E0E11: public key “Launchpad PPA for ibus-dev” imported

  gpg: Total number processed: 1

  gpg: imported: 1 (RSA: 1)

  下一步是让apt-get 来使用这个公钥

  $gpg –armor -–export 985E0E11| sudo apt-key add -

  注意apt-key add要用特权用户来运行才可以,也就是要用sudo来运行,不然有如下错误提示:

  gpg: no writable keyring found: eof

  gpg: error reading `-’: general error

  gpg: import from `-’ failed: general error

  导入成功后sudo apt-get update就不会有错误提示了。

8、相关网站

http://www.crifan.com/ubuntu_change_sources_list_to_163/

http://wiki.ubuntu.org.cn/%E6%BA%90%E5%88%97%E8%A1%A8