?? 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 + -