ubuntu使用APT进行包管理,APT把repositories列表保存在sources.list文件中。
文件/etc/apt/sources.list是一个普通可编辑的文本文件,保存了ubuntu软件更新的源服务器的地址。
NAME
sources.list - List of configured APT data sources
DESCRIPTION
The source list /etc/apt/sources.list is designed to support any number of active sources and a variety of source media. The file lists one source per line, with the most preferred source listed first.The information available from the configured sources is acquired by apt-get update (or by an equivalent command from another APT front-end).
Each line specifying a source starts with type (e.g. deb-src) followed by options and arguments for this type.
Individual entries cannot be continued onto a following line. Empty lines are ignored, and a # character anywhere on a line marks the remainder of that line as a comment.
SOURCES.LIST.D
The /etc/apt/sources.list.d directory provides a way to add sources.list entries in separate files. The format is the same as for the regular sources.list file. File names need to end with .list and may only contain letters (a-z and A-Z), digits (0-9), underscore (_), hyphen (-) and period (.) characters. Otherwise APT will print a notice that it has ignored a file, unless that file matches a pattern in the Dir::Ignore-Files-Silently configuration list - in which case it will be silently ignored.
THE DEB AND DEB-SRC TYPES
The deb type references a typical two-level Debian archive, distribution/component. The distribution is generally an archive name like stable or testing or a codename like wheezy or jessie while component is one of main, contrib or non-free.
The deb-src type references a Debian distribution's source code in the same form as the deb type. A deb-src line is required to fetch source indexes.
The format for a sources.list entry using the deb and deb-src types is:
deb [ options ] uri suite [component1] [component2] [...]
Alternatively a rfc822 style format is also supported:
Types: deb deb-src
URIs: http://example.com
Suites: stable testing
Sections: component1 component2
Description: short
long long long
[option1]: [option1-value]
Types: deb
URIs: http://another.example.com
Suites: experimental
Sections: component1 component2
Enabled: no
Description: short
long long long
[option1]: [option1-value]
The URI for the deb type must specify the base of the Debian distribution, from which APT will find the information it needs. suite can specify an exact path, in which case the components must be omitted and suite must end with a slash (/). This is useful for the case when only a particular sub-section of the archive denoted by the URI is of interest. If suite does not specify an exact path, at least one component must be present.
suite may also contain a variable, $(ARCH) which expands to the Debian architecture (such as amd64 or armel) used on the system. This permits architecture-independent sources.list files to be used. In general this is only of interest when specifying an exact path, APT will automatically generate a URI with the current architecture otherwise.
In the traditional style sources.list format since only one distribution can be specified per line it may be necessary to have multiple lines for the same URI, if a subset of all available distributions or components at that location is desired. APT will sort the URI list after it has generated a complete set internally, and will collapse multiple
references to the same Internet host, for instance, into a single connection, so that it does not inefficiently establish an FTP connection, close it, do something else, and then re-establish a connection to that same host. This feature is useful for accessing busy FTP sites with limits on the number of simultaneous anonymous users. APT also parallelizes connections to different hosts to more effectively deal with sites with low bandwidth.
options is always optional and needs to be surrounded by square brackets. It can consist of multiple settings in the form setting=value. Multiple settings are separated by spaces. The following settings are supported by APT (note however that unsupported settings will be ignored silently):
? arch=arch1,arch2,... can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded.
? arch+=arch1,arch2,... and arch-=arch1,arch2,... which can be used to add/remove architectures from the set which will be downloaded.
? trusted=yes can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. This disables parts of apt-secure(8) and should therefore only be used in a local and trusted context. trusted=no is the opposite which handles even correctly authenticated sources as not authenticated.
It is important to list sources in order of preference, with the most preferred source listed first. Typically this will result in sorting by speed from fastest to slowest (CD-ROM followed by hosts on a local network, followed by distant Internet hosts, for example).
Some examples:
deb http://ftp.debian.org/debian wheezy main contrib non-free
deb http://security.debian.org/ wheezy/updates main contrib non-free
URI SPECIFICATION
The currently recognized URI types are:
file
The file scheme allows an arbitrary directory in the file system to be considered an archive. This is useful for NFS mounts and local mirrors or archives.
cdrom
The cdrom scheme allows APT to use a local CD-ROM drive with media swapping. Use the apt-cdrom(8) program to create cdrom entries in the source list.
http
The http scheme specifies an HTTP server for the archive. If an environment variable http_proxy is set with the format http://server:port/, the proxy server specified in http_proxy will be used. Users of authenticated HTTP/1.1 proxies may use a string of the format http://user:pass@server:port/. Note that this is an insecure method of
authentication.
ftp
The ftp scheme specifies an FTP server for the archive. APT's FTP behavior is highly configurable; for more information see the apt.conf(5) manual page. Please note that an FTP proxy can be specified by using the ftp_proxy environment variable. It is possible to specify an HTTP proxy (HTTP proxy servers often understand FTP URLs) using this environment variable and only this environment variable. Proxies using HTTP specified in the configuration file will be ignored.
copy
The copy scheme is identical to the file scheme except that packages are copied into the cache directory instead of used directly at their location. This is useful for people using removable media to copy files around with APT.
rsh, ssh
The rsh/ssh method invokes RSH/SSH to connect to a remote host and access the files as a given user. Prior configuration of rhosts or RSA keys is recommended. The standard find and dd commands are used to perform the file transfers from the remote host.
adding more recognizable URI types
APT can be extended with more methods shipped in other optional packages, which should follow the naming scheme apt-transport-method. For instance, the APT team also maintains the package apt-transport-https, which provides access methods for HTTPS URIs with features similar to the http method. Methods for using e.g. debtorrent are also available - see apt-transport-debtorrent(1).
EXAMPLES
Uses the archive stored locally (or NFS mounted) at /home/jason/debian for stable/main, stable/contrib, and stable/non-free.
deb file:/home/jason/debian stable main contrib non-free
As above, except this uses the unstable (development) distribution.
deb file:/home/jason/debian unstable main contrib non-free
Source line for the above
deb-src file:/home/jason/debian unstable main contrib non-free
The first line gets package information for the architectures in APT::Architectures while the second always retrieves amd64 and armel.
deb http://ftp.debian.org/debian wheezy main
deb [ arch=amd64,armel ] http://ftp.debian.org/debian wheezy main
Uses HTTP to access the archive at archive.debian.org, and uses only the hamm/main area.
deb http://archive.debian.org/debian-archive hamm main
Uses FTP to access the archive at ftp.debian.org, under the debian directory, and uses only the wheezy/contrib area.
deb ftp://ftp.debian.org/debian wheezy contrib
Uses FTP to access the archive at ftp.debian.org, under the debian directory, and uses only the unstable/contrib area. If this line appears as well as the one in the previous example in sources.list a single FTP session will be used for both resource lines.
deb ftp://ftp.debian.org/debian unstable contrib
Uses HTTP to access the archive at ftp.tlh.debian.org, under the universe directory, and uses only files found under unstable/binary-i386 on i386 machines, unstable/binary-amd64 on amd64, and so forth for other supported architectures. [Note this example only illustrates how to use the substitution variable; official debian archives are not structured like this]
deb http://ftp.tlh.debian.org/universe unstable/binary-$(ARCH)/
SEE ALSO
apt-cache(8)apt.conf(5)
Taking an example from this page, suppose you wanted to install chef (from opscode), what you'd do is:
?Create and open a file named opscode.list:
sudo vim /etc/apt/sources.list.d/opscode.list
?Add the required line and save the file:
deb http://apt.opscode.com/ oneiric main
The above steps can be combined to make a single command:
sudo echo "deb http://apt.opscode.com/ onereic main" > /etc/apt/sources.list.d/opscode.list
Note: The command contains onereic because the codename of the Ubuntu you're using is Onereic. Had you been using Precise (12.04), you'd have writter precise.
参考:
1 repo wiki: http://wiki.ubuntu.org.cn/index.php?title=UbuntuHelp:Repositories/Ubuntu&variant=zh-cn
2 用命令管理repo: http://wiki.ubuntu.org.cn/index.php?title=UbuntuHelp:Repositories/CommandLine&variant=zh-cn
3 创建本地源: http://wiki.ubuntu.org.cn/index.php?title=UbuntuHelp:Repositories/Personal/zh&variant=zh-cn
4 ubuntu源列表: http://wiki.ubuntu.org.cn/Qref/Source
5 ubuntu版本代号:https://wiki.ubuntu.com/Releases
6 ubuntu种类:https://wiki.ubuntu.com/UbuntuFlavors
7 官方软件包搜索:http://packages.ubuntu.com/
参考:http://www.cnblogs.com/jiangz/p/4076811.html?utm_source=tuicool&utm_medium=referral
文件/etc/apt/sources.list是一个普通可编辑的文本文件,保存了ubuntu软件更新的源服务器的地址。
/etc/apt/sources.list.d/*.list(*代表一个文件名,只能由字母、数字、下划线、英文句号组成)和sources.list功能一样。sources.list.d目录下的*.list文件为在单独文件中写入源的地址提供了一种方式,通常用来安装第三方的软件。
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
如上是ubuntu官方sources.list文件内容,具体地含义如下:
每一行的开头是deb或者deb-src,分别表示直接通过.deb文件进行安装和通过源文件的方式进行安装。
deb或者deb-src字段之后,是一段URL,之后是五个用空格隔开的字符串,分别对应相应的目录结构。
在浏览器中输入http://archive.ubuntu.com/ubuntu/,并进入dists目录,可以发现有5个目录和前述sources.list文件中的第三列字段相对应。任选其中一个目录进入,可以看到和sources.list后四列相对应的目录结构。
更多内容可以使用man source.list获得。
ubuntu官方有自身的软件源,直接从官方的软件源获取数据的速度比较慢。而通过国内的一些的源的镜像进行更新一般能够获得比官方源更快的速度,不过不同国内的源的下载速度也会不一样。这里给出了较为详细的ubuntu软件源列表,个人现在觉得选取ubuntu软件源的方法是首先选择位于相同地区的源,然后进行ping操作,时延不是太高即可。对比aliyun、sohu、ubuntu官方ping的数据,可以发现aliyun的源在时延上表现最好。
最近在12.10上使用sudo apt-get install命令时,出现了404 not found的问题,此时ping archive.ubuntu.com可以ping通,在http://archive.ubuntu.com/ubuntu/dists/ 目录下已经没有quantal相关目录。具体原因是ubuntu对12.10的维护时间不超过一年,超过了相应的时间之后,对应的源的文件都转移到了http://old-releases.ubuntu.com/ubuntu/dists/ 目录下。ubuntu发布的版本可以从这里看到,从中一方面可以看到ubuntu数字版本号和英文名称的对应关系,也可以看到以04结尾的版本LTS标识,标识长期维护,这些版本的源在archive.ubuntu.com中呆的时间就比较长。
解决方法:
1)使用gedit将sources.list文件打开
sudo gedit /etc/apt/sources.list
2)进入替换界面(Search->Replace或者ctrl+H)进行替换操作
1)下载一个deb格式的软件kismet
curl https://www.kismetwireless.net/code/dists/quantal/kismet/binary-i386/kismet-2011.03.2.i386.deb >kismet-2011.03.2.i386.deb
2)安装kismet
dpkg -i kismet-2011.03.2.i386.deb
3)根据提示安装相关包
sudo apt-get install libnl2
[1]repository - How do you tell apt to use files in /etc/apt/sources.list.d - Ask Ubuntu
[2]源列表 - Ubuntu中文
[3]Releases - Ubuntu Wiki
[4]How to fix Ubuntu/Debian apt-get 404 Not Found Package Repository Errors (Saucy, Raring, Quantal, Oneiric, Natty…) | sMyl.es
[5]How do I install a .deb file via the command line askubuntu
[6]Ubuntu .deb包安装方法 - 程序生活 - 博客频道 - CSDN.NET