读懂Debian/Ubuntu系列的sources.list格式

# Debian “testing” (presently the same as “Sarge”)
deb http :// ftp.us.debian.org / debian testing main contrib non-free
deb-src http://ftp.us.debian.org/debian testing main contrib non-free
deb http:// security .debian.org/ testing/updates main contrib
deb-src http://security.debian.org/ testing/updates main contrib
deb http://www.debian-multimedia.org/ testing main
deb-src http://www.debian-multimedia.org/ testing main
deb http://ftp.tw.debian.org/debian testing main  non-free contrib
deb-src http://ftp.tw.debian.org/debian testing main non-free contrib
贴一段自己的sources.list,用不同颜色标出不同的内容再分别解释。

首先说明,/etc/apt/下的sources.list只是一个普通的文本文件,所以可以用任何一款文本编辑器来编辑它,当然在Linux下面,你还要考虑到有没有编辑权限的问题。
什么是文本?就是txt文件啦。
#

最先开始的,是很不起眼的”#“符号,这在sources.list文件中起注释的作用。注释是什么意思?注释的本意是解释和说明,目的是让人能看 懂;人能看懂,机器就看不懂了?对,”#“注释的另外一个用处就是为了让机器看不懂这一行的内容,看不懂就忽略掉;需要机器看懂的内容,另起一行单独写 吧。

我曾经有段时间需要反复在教育网和电信网中切换,为了保证更新速度,Debian的更新源也分成了教育网和电信不同的源,那如何切换,才能上 Debian只从我指定的源更新呢?这个时候就轮到”#“派上用场了,只需要在不想让机器读取的地址前面加上”#“,机器就会忽略掉这个地址了。有多行地 址也不怕,用Vim的列模式给多行源地址的前面添加一个”#“注释,也只是一眨眼的事。

通常 ,在利用了”#“之后,我的源列表会是这个样子


deb & deb-src

其次,在没有”#“开头的行,通常是以deb或deb-src打头的,这也是源列表里最重要的内容,系统更新时机器能够读懂的内容,就从这一列开 始。用过Debian或Ubuntu的或许都知道deb文件是Debian系列的软件包格式。因此,用deb开头,后面再跟上一串网址的那一行,意思就是 告诉更新管理器:”去那网址里下deb格式的软件包来安装“;如果是deb-src开头,就是去下载源码包再进行编译安装。


http & ftp & cdrom &  file
告诉机器去下载什么格式的文件后,然后还得具体告诉它去哪个地址下载,通常情况下,我们都是去网络中下载软件,因此,最常见的源中,都是http和ftp开始的地址,因为http和ftp协议就是最通用的网络协议。

cdrom 则是光驱的意思,用光盘安装好系统之后,第一次更改源列表的时候,打开sources.list,就可以看到以”deb cdrom“打头的地址,这是因为安装系统时所需要的软件包,都是从放在cdrom的光盘中找到的呀。
硬盘安装也是这样,也是先把下载好的镜像文件虚拟成光驱后再安装的。

file 是本地文件的意思,如果把deb或deb-src包下载到本地某个文件夹中,就可以用”deb file:“格式来安装了。这种格式的地址很少见,因为如果是deb包,完全可以用”dpkg -i *.deb“ 命令来安装;源码包,也是可以编译的。


ftp.us.debian.org

再然后的其实没什么好说,就是普通的网址,之所以把它单独列出来,是因为我们可以用这个网址访问来判断更新源的速度,比方说网上寻找源的时候往往搜到一大堆地址,这时就可以通过这一部分大致判断哪个可能更快点。在教育网时,我用的就是http://debian.ustc.edu.cn , 在电信网,就用http://ftp.us.debian.org和http://ftp.tw.debian.org,看清楚了,有us和tw,表示这 两个服务器是放在米国和台湾的,无它,因为感觉这两个源比较快而已。当然,国内也有比较快的地址,比如说国内最早最有名的,以前是CN99现在由网易支持 的http://mirrors.163.com/ ,还有据说被Ubuntu官方认可的http://mirrors.sohu.com 源。

security & backport
如果网址后面带有security,顾名思义,这是表示安全的更新。
在Ubuntu下面,可能还有backport开头的源,按维基的说法“让用户可以在不更新包库的情况下,获得和使用各类新版的应用软件。”实际上可以理解为尽量提供兼容不同版本的软件源。


debian testing
接下来的这两个应该和在一起说,前者,表示你使用的操作系统发行版;后者,表示该发行版的具体版本号或代号。因为软件总是有适用系统的,就像在 Windows下面也有支持不支持 Win98,支持不支持Vista/Windows7等不同的情况,到了以自由著称的Linux,这种情况就更严重了,Debian不能用Fedora 的,Arch也不能用Debian的,甚至同出一门的Debian和Ubuntu的也不能混用。

Debian/Ubuntu系列,查看版本号的命令是cat /etc/issue或者sudo lsb_release -a


main contrib non-free

最后是软件包分类,分类标准是不同版权协议,具体解释如下:
main:完全遵循Debian  自由软件准则 /即DFSG的软件包;
contrib:软件包均遵循DFSG自由使用原则,但是其使用了某些不符合DFSG的第三方库;
non-free:不符合DFSG的软件包。

最后提示一点:“http://ftp.us.debian.org/debian testing main contrib non-free”中,debian与后面的testing之间可以用“/”或空格断开。testing与后面的main等也是如此,但
最后的“main contrib non-free”三者是属于同一级目录的地址,因此只能用空格,不可以用“/”

 

转自:http://windorain.net/sources-list-format/

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
linux-debian软件安装包sources.list 路径 /etc/apt # deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official amd64 CD Binary-1 20150906-11:13]/ jessie main # deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official amd64 CD Binary-1 20150906-11:13]/ jessie main # deb http://ftp.debian.org/debian/ experimental main deb http://mirrors.ustc.edu.cn/debian/ jessie main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian/ jessie main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ jessie-proposed-updates main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian/ jessie-proposed-updates main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ jessie-updates main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian/ jessie-updates main contrib non-free # deb http://mirrors.163.com/debian/ jessie main non-free contrib # deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib # deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib # deb-src http://mirrors.163.com/debian/ jessie main non-free contrib # deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib # deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib # deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib # deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib # deb http://cs3.swfu.edu.cn/debian/ jessie main contrib non-free # Line commented out by installer because it failed to verify: # deb http://security.debian.org/ jessie/updates main # Line commented out by installer because it failed to verify: # deb-src http://security.debian.org/ jessie/updates main # jessie-updates, previously known as 'volatile' # A network mirror was not selected during install. The following entries # are provided as examples, but you should amend them as appropriate # for your mirror of choice. # deb http://ftp.debian.org/debian/ jessie-updates main # deb-

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值