📄 6.htm
字号:
</PRE>
<P>这里“<SAMP>Package:</SAMP>”后不能使用通配符如“<SAMP>libc6*</SAMP>”,如果要保持所有与<CODE>glibc</CODE>源码包相关的二进制包的版本同步,可以明确的列出它们。
<P>该命令可以显示处于“阻止”状态的软件包: <PRE> dpkg --get-selections "*"|grep -e "hold$"
</PRE>
<HR>
<A name=s-mixedsys></A>
<H3>6.4.7 stable/testing/unstable混合系统</H3>
<P><CODE>apt-show-versions</CODE>可以列出发行版中可用软件包的版本。 <PRE> $ apt-show-versions | fgrep /testing | wc
... 你有多少testing软件包
$ apt-show-versions -u
... 列出可升级的软件包
$ apt-get install `apt-show-versions -u -b | fgrep /unstable`
... 将所有unstable软件包升级到最新版本
</PRE>
<HR>
<A name=s-cache></A>
<H3>6.4.8 删除缓存包文件</H3>
<P>使用APT安装软件包会在<CODE>/var/cache/apt/archives</CODE>目录留下缓存文件,要清除这些文件可使用: <PRE> # apt-get autoclean # removes only useless package files
# apt-get clean # removes all cached package files
</PRE>
<HR>
<A name=s-record></A>
<H3>6.4.9 记录/拷贝系统配置</H3>
<P>对软件包选择情况进行本地备份: <PRE> $ dpkg --get-selections "*" ><VAR>myselections</VAR> # or use \*
</PRE>
<P><SAMP>“*”</SAMP>使<SAMP><VAR>myselections</VAR></SAMP>包含那些被指定“完全删除(purge)”的文件。
<P>你可将这个文件发送到另一台电脑并在那儿按文件中的选择进行软件包安装。 <PRE> # dselect update
# dpkg --set-selections <<VAR>myselections</VAR>
# apt-get -u dselect-upgrade # <VAR>or</VAR> dselect install
</PRE>
<HR>
<A name=s-port></A>
<H3>6.4.10 向<SAMP>stable</SAMP>系统引入软件包</H3>
<P>对stable系统进行部分升级,在软件运行环境中重新编译源码的确是个诱人的想法,这样可以避免由于关联关系不得不对大量软件包升级。首先,将下列镜像源加入<CODE>/etc/apt/sources.list</CODE>:
<PRE> deb-src http://http.us.debian.org/debian testing \
main contrib non-free
deb-src http://non-us.debian.org/debian-non-US testing/non-US \
main contrib non-free
deb-src http://http.us.debian.org/debian unstable \
main contrib non-free
deb-src http://non-us.debian.org/debian-non-US unstable/non-US \
main contrib non-free
</PRE>
<P>由于屏幕输出的限制,上述每条<SAMP>deb-src</SAMP>命令均分成了2行,实际上在<CODE>sources.list</CODE>中它们均为单行。
<P>然后下载源码并在本地生成软件包: <PRE> $ apt-get source <VAR>package</VAR>
$ dpkg-source -x <VAR>package.dsc</VAR>
$ cd <VAR>package-version</VAR>
... 查找需要的软件包(编译所需的关联包列在.dsc文件中)并安装它们,
你还需要“fakerroot”软件包。
$ dpkg-buildpackage -rfakeroot
...or (no sig)
$ dpkg-buildpackage -rfakeroot -us -uc # use "debsign" later if needed
...Then to install
$ su -c "dpkg -i <VAR>packagefile.deb</VAR>"
</PRE>
<P>通常,需要安装一些带“-dev”后缀的软件包以满足关联关系。<CODE>debsign</CODE>在<CODE>devscripts</CODE>软件包中。<CODE>auto-apt</CODE>可以轻松解决这些关联问题。请使用<CODE>fakeroot</CODE>,如是没有必要,就别使用root帐号。
<P>在Woody中,这些关联问题已被简化。例如,编译<CODE>pine</CODE>源码包: <PRE> # apt-get build-dep pine
# apt-get source -b pine
</PRE>
<HR>
<A name=s-local></A>
<H3>6.4.11 本地软件包文件</H3>
<P>为了创建与APT和dselect系统兼容的本地软件包文件,需要创建<CODE>Packages</CODE>(Packages),包中文件要放在特定的目录树中。
<P>Debian官方包文件喜欢存放于本地deb仓库,下面就来创建仓库: <PRE> # apt-get install dpkg-dev
# cd <VAR>/usr/local</VAR>
# install -d <VAR>pool</VAR> # 软件包存放的物理地址
# install -d dists/<VAR>unstable</VAR>/<VAR>main</VAR>/binary-<VAR>i386</VAR>
# ls -1 <VAR>pool</VAR> | sed 's/_.*$/ <VAR>priority</VAR> <VAR>section</VAR>/' | uniq > <VAR>override</VAR>
# editor <VAR>override</VAR> # adjust <VAR>priority</VAR> and <VAR>section</VAR>
# dpkg-scanpackages <VAR>pool</VAR> <VAR>override</VAR> <VAR>/usr/local</VAR>/ \
> dists/<VAR>unstable</VAR>/<VAR>main</VAR>/binary-<VAR>i386</VAR>/Packages
# cat > dists/<VAR>unstable</VAR>/<VAR>main</VAR>/Release << EOF
Archive: <VAR>unstable</VAR>
Version: <VAR>3.0</VAR>
Component: <VAR>main</VAR>
Origin: <VAR>Local</VAR>
Label: <VAR>Local</VAR>
Architecture: <VAR>i386</VAR>
EOF
# echo "deb file:<VAR>/usr/local</VAR> <VAR>unstable</VAR> <VAR>main</VAR>" \
>> /etc/apt/sources.list
</PRE>
<P>还可以这样快速创建一个本地deb仓库: <PRE> # apt-get install dpkg-dev
# mkdir <VAR>/usr/local/debian</VAR>
# mv <VAR>/some/where/package.deb</VAR> <VAR>/usr/local/debian</VAR>
# dpkg-scanpackages <VAR>/usr/local/debian</VAR> /dev/null | \
gzip - > <VAR>/usr/local/debian</VAR>/Packages.gz
# echo "deb file:<VAR>/usr/local/debian</VAR> ./" >> /etc/apt/sources.list
</PRE>
<P>在<CODE>/etc/apt/sources.list</CODE>中设置相应镜像源入口地址,就可以通过HTTP或FTP方式远程访问存放在其中的包文件了。
<HR>
<A name=s-alien></A>
<H3>6.4.12 转化或安装外来二进制软件包</H3>
<P><CODE>alien</CODE>可将其它格式的二进制软件包如Redhat的<SAMP>rpm</SAMP>、Stampede的<SAMP>slp</SAMP>、Slackware的<SAMP>tgz</SAMP>和Solaris的<SAMP>pkg</SAMP>等转化成Debian的<SAMP>deb</SAMP>格式软件包,如果你想在自己的系统上使用别的Linux发行版中的软件包,可使用<CODE>alien</CODE>将它转化成系统首选的软件包格式后安装。<CODE>alien</CODE>还支持LSB的软件包。
<HR>
<A name=s-debsums></A>
<H3>6.4.13 校验已安装软件包</H3>
<P><CODE>debsums</CODE>可以校验已安装软件包的MD5编码,对某些软件包没有可用的MD5编码,系统管理员可使用一个临时的解决办法: <PRE> # cat >>/etc/apt/apt.conf.d/90debsums
DPkg::Post-Install-Pkgs {"xargs /usr/bin/debsums -sg";};
^D
</PRE>
<P>per Joerg Wendland <joergland@debian.org> (untested).
<HR>
<A name=s-spy></A>
<H3>6.4.14 优化<CODE>sources.list</CODE></H3>
<P>简而言之,我尝试过用各种优化方法来创建<CODE>sources.list</CODE>,但任何一种方法对我这个住在美国的人来说都没有明显的改善。最后我还是用<CODE>apt-setup</CODE>手工选择近一点的站点。
<P><CODE>apt-spy</CODE>会根据站点回应时间和带宽自动创建<CODE>sources.list</CODE>。<CODE>netselect-apt</CODE>会创建一个更完整的<CODE>sources.list</CODE>文件,但它使用更落后的方法来选择镜像站点(比较ping
time)。 <PRE> # apt-get install apt-spy
# cd /etc/apt ; mv sources.list sources.list.org
# apt-spy -d testing -l sources.apt
</PRE>
<HR>
<A name=s-pecuriarities></A>
<H2>6.5 其它Debian特性</H2>
<HR>
<A name=s-dpkg-divert></A>
<H3>6.5.1 <CODE>dpkg-divert</CODE>命令</H3>
<P>使用文件<STRONG>转移</STRONG>(diversions)的方法可以强令<CODE>dpkg</CODE>将文件安装到<STRONG>转移</STRONG>目录而非默认目录。对于某个引起冲突的文件,可以在Debian软件包脚本中使用<STRONG>Diversions</STRONG>将它安装到别的目录。系统管理员还可以使用diversion来重载软件包配置文件,或者用来保留某些旧配置文件(这些文件没有在<STRONG>conffiles</STRONG>中登记)当安装新版软件时这些文件会被覆盖。(参阅<A
href="http://qref.sourceforge.net/Debian/reference/ch-system.zh-cn.html#s-conffile">保存本地设置,
第 2.2.4 节</A>)。 <PRE> # dpkg-divert [--add] <VAR>filename</VAR> # add "diversion"
# dpkg-divert --remove <VAR>filename</VAR> # remove "diversion"
</PRE>
<P>记住,不到万不得已不要使用<CODE>dpkg-divert</CODE>。
<HR>
<A name=s-equivs></A>
<H3>6.5.2 <CODE>equivs</CODE>软件包</H3>
<P>如果你从源码编译程序,最好将它做成本地Debian化软件包(<SAMP>*.deb</SAMP>)。最新的方法是使用<SAMP>equivs</SAMP>。
<PRE> Package: equivs
Priority: extra
Section: admin
Description: Circumventing Debian package dependencies
This is a dummy package which can be used to create Debian
packages, which only contain dependency information.
</PRE>
<HR>
<A name=s-alternatives></A>
<H3>6.5.3 自选命令</H3>
<P>想用<CODE>vi</CODE>命令启动<CODE>vim</CODE>,可使用<CODE>update-alternatives</CODE>来定义:
<PRE> # update-alternatives --display vi
...
# update-alternatives --config vi
Selection Command
-----------------------------------------------
1 /usr/bin/elvis-tiny
2 /usr/bin/vim
*+ 3 /usr/bin/nvi
Enter to keep the default[*], or type selection number: 2
</PRE>
<P>Debian自选命令设定系统中的这些项目,都是<CODE>/etc/alternatives</CODE>下的链接文件。
<P>想设置你喜爱的X
window环境,执行<CODE>update-alternatives</CODE>来指定<CODE>/usr/bin/x-session-manager</CODE>和<CODE>/usr/bin/x-window-manager</CODE>。详情参阅<A
href="http://qref.sourceforge.net/Debian/reference/ch-tune.zh-cn.html#s-custom-x">自定义X会话,
第 9.4.5.1 节</A>。
<P><CODE>/bin/sh</CODE>是指向<CODE>/bin/bash</CODE>或<CODE>/bin/dash</CODE>的链接。想兼容旧的Bash脚本,使用<CODE>/bin/bash</CODE>比较保险,但更好还是使用<CODE>/bin/dash</CODE>,因为它更符合POSIX标准。升级到2.4版Linux内核,系统一般将它设置为<CODE>/bin/dash</CODE>。
<HR>
<A name=s-sys-v></A>
<H3>6.5.4 System-V <CODE>init</CODE>文件和运行级别</H3>
<P>可在<CODE>/etc/inittab</CODE>中设定系统启动的默认运行级别(runlevel)。
<P>不同于其它的发行版,Debian将运行级别的管理职责完全赋予系统管理员。Debian更倾向于使用<CODE>update-rc.d</CODE>脚本来管理它那System-V风格的<CODE>init</CODE>。
<P>下面的命令表示,按优先级数字20(normal)所指定的次序,分别在runlevel
1、2、3中启动<CODE>/etc/init.d/<VAR>name</VAR></CODE>,在runlevel 4、5中停止它们: <PRE> # update-rc.d <VAR>name</VAR> start 20 1 2 3 . stop 20 4 5 .
</PRE>
<P>要删除<CODE>init.d</CODE>脚本中存在的符号链接可执行: <PRE> # update-rc.d -f <VAR>name</VAR> remove
</PRE>
<P>要编辑运行级别,我通常在<CODE>mc</CODE>中用<SAMP>Alt-Enter</SAMP>拷贝链接名,然后在shell提示符下使用<CODE>mv</CODE>命令手工编辑,例如:
<PRE> # mv S99xdm K99xdm # 禁用xdm (X display manager)
</PRE>
<P>有时为了进行临时调试,我甚至在<CODE>init.d</CODE>脚本的开头加入<SAMP>exit
0</SAMP>来禁用一个daemon,反正它们都在<SAMP>conffiles</SAMP>登记过。
<HR>
<A name=s-disables></A>
<H3>6.5.5 停止daemon服务</H3>
<P>Debian发行版非常注重系统安全,并期望系统管理员能担此重任。它将系统的易用性放在了第二位,许多daemon服务都定位在最高安全级别,因而,默认安装状态下系统只启动最少的(甚至没有)可用的服务。
<P>如果拿不定把握(有关Exim、DHCP...),可执行<SAMP>ps
aux</SAMP>或检查<CODE>/etc/init.d/*</CODE>和<CODE>/etc/inetd.conf</CODE>下的内容,还可以使用<A
href="http://qref.sourceforge.net/Debian/reference/ch-tune.zh-cn.html#s-loginctrl">通过PAM和login实现访问权限管理,
第 9.2.1
节</A>中提到的方法检查<CODE>/etc/hosts.deny</CODE>。<CODE>pidof</CODE>命令也很有用(参阅<CODE>pidof(8)</CODE>)
<P>在新版的Debian中,默认状态下X11不允许TCP/IP(远程)连接。参阅<A
href="http://qref.sourceforge.net/Debian/reference/ch-tune.zh-cn.html#s-xtcp">X的TCP/IP连接,
第 9.4.6 节</A>,使用SSH进行X传送也是禁用的,参阅<A
href="http://qref.sourceforge.net/Debian/reference/ch-tune.zh-cn.html#s-xssh">X远程联接:<CODE>ssh</CODE>,
第 9.4.8 节</A>。
<HR>
[ <A
href="http://qref.sourceforge.net/Debian/reference/ch-woody.zh-cn.html">上一页</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/reference.zh-cn.html#contents">目录</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-preface.zh-cn.html">1</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-system.zh-cn.html">2</A> ]
[ <A
href="http://qref.sourceforge.net/Debian/reference/ch-install.zh-cn.html">3</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-tutorial.zh-cn.html">4</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-woody.zh-cn.html">5</A> ]
[ 6 ] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-kernel.zh-cn.html">7</A> ]
[ <A
href="http://qref.sourceforge.net/Debian/reference/ch-tips.zh-cn.html">8</A> ] [
<A href="http://qref.sourceforge.net/Debian/reference/ch-tune.zh-cn.html">9</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-gateway.zh-cn.html">10</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-edit.zh-cn.html">11</A> ]
[ <A
href="http://qref.sourceforge.net/Debian/reference/ch-vcs.zh-cn.html">12</A> ] [
<A
href="http://qref.sourceforge.net/Debian/reference/ch-program.zh-cn.html">13</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-gnupg.zh-cn.html">14</A> ]
[ <A
href="http://qref.sourceforge.net/Debian/reference/ch-support.zh-cn.html">15</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ap-appendix.zh-cn.html">A</A>
] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-kernel.zh-cn.html">下一页</A>
]
<HR>
<P>Debian 参考手册
<ADDRESS>CVS, 星期三 四月 28 19:36:38 UTC 2004<BR><BR>Osamu Aoki <CODE><A
href="mailto:osamu@debian.org">osamu@debian.org</A></CODE><BR>Translator: Hao
"Lyoo" Liu <CODE><A
href="mailto:iamlyoo@163.net">iamlyoo@163.net</A></CODE><BR><A
href="http://qref.sourceforge.net/Debian/reference/ap-appendix.zh-cn.html#s-authors">作者,
第 A.1 节</A><BR><BR></ADDRESS>
<HR>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -