?? 4.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0067)http://qref.sourceforge.net/Debian/reference/ch-tutorial.zh-cn.html -->
<HTML><HEAD><TITLE>Debian 參考手冊 - Debian指南</TITLE>
<META http-equiv=content-type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.3790.118" name=GENERATOR></HEAD>
<BODY><A name=ch-tutorial></A>
<HR>
[ <A
href="http://qref.sourceforge.net/Debian/reference/ch-install.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>
] [ 4 ] [ <A
href="http://qref.sourceforge.net/Debian/reference/ch-woody.zh-cn.html">5</A> ]
[ <A
href="http://qref.sourceforge.net/Debian/reference/ch-package.zh-cn.html">6</A>
] [ <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-woody.zh-cn.html">下一頁</A>
]
<HR>
<H1>Debian 參考手冊 <BR>第 4 章 - Debian指南 </H1>
<HR>
<P>本章為那些初涉Linux世界的新手指出了基本方向。如果你接觸Linux已有一段時間,可以當成是一次實戰測驗。
<HR>
<A name=s4.1></A>
<H2>4.1 信息資源</H2>
<P>到<CODE><A href="http://www.debian.org/doc/">Debian Documentation Project
(DDP)</A></CODE>看看,那兒有最權威的Debian參考資料。其中的許多文檔都安裝在<CODE>/usr/share/doc/</CODE>下。還可以到<CODE>/usr/share/doc-base/</CODE>看看,那兒有這些文檔的打印文件。在<CODE>~/.bash_profile</CODE>中添加<SAMP>export
CDPATH=.:/usr/share/doc:/usr/src/local</SAMP>,這樣更容易訪問這些文檔目錄。
<P>到<CODE><A href="http://www.tldp.org/">Linux Documentation Project
(LDP)</A></CODE>看看,那兒有最權威的通用Linux參考資料。LDP資料通常安裝在<CODE>/usr/share/doc/HOWTO/</CODE>目錄下。
<P>瀏覽本地或遠程FTP站點的文檔,可在Midnight Commander中按下<SAMP>F9</SAMP>(參閱<A
href="http://qref.sourceforge.net/Debian/reference/ch-tutorial.zh-cn.html#s-mc">Midnight
Commander (MC), 第 4.3 節</A>)。
<HR>
<A name=s4.2></A>
<H2>4.2 Linux控制臺</H2>
<HR>
<A name=s-login></A>
<H3>4.2.1 登錄</H3>
<P>在普通Linux系統中,有6個獨立的偽終端(pseudo-terminals)。同時按下<SAMP>Left-Alt</SAMP>鍵和<SAMP>F1</SAMP>–<SAMP>F6</SAMP>鍵可在這些偽終端間切換。每個偽終端均需單獨登錄。多用戶環境是Unix最鮮明的特征,而且一用就上癮。
<P>使用普通用戶帳號工作是個很好的Unix習慣。不得不承認,我過去常僅僅為圖方便而濫用超級用戶帳號(root)。
<P>現在,我通常使用一個普通用戶帳號,使用<SAMP>sudo</SAMP>、<SAMP>super</SAMP>或<SAMP>su
-c</SAMP>來獲得有限的root訪問權限。
<HR>
<A name=s-newuser></A>
<H3>4.2.2 添加用戶</H3>
<P>系統安裝完畢,我通常會添加一個普通用戶帳號,如果用戶名為“penguin”, <PRE> # adduser penguin
</PRE>
<P>就會創建一個這樣帳號。
<P>使用<SAMP>vigr</SAMP>命令編輯<CODE>/etc/group</CODE>: <PRE> adm:x:4:admin
src:x:40:admin, debian, ...
...
</PRE>
<P>在系統默認安裝狀態下,<SAMP>adm</SAMP>用戶組成果對<CODE>/var/log</CODE>下的許多日志文件具有讀權限,并可使用<CODE>xconsole</CODE>。<SAMP>staff</SAMP>用戶組擁有<CODE>/home</CODE>,適用于進行用戶帳號維護工作的用戶,而src用戶組擁有<CODE>/usr/src</CODE>,用來存放那些完成內核編譯等工作的用戶。有關用戶及用戶組的規范描述可參閱最新的<CODE><A
href="http://qref.sourceforge.net/usr/share/doc/base-passwd/users-and-groups.html">users-and-groups</A></CODE>。
<P>我個人使用<SAMP>adm</SAMP>用戶組存放那些具有管理員職責和單獨<CODE>su</CODE>特權的用戶(參閱<A
href="http://qref.sourceforge.net/Debian/reference/ch-tune.zh-cn.html#s-wheel">“為什么GNU
<CODE>su</CODE>命令不支持<SAMP>wheel</SAMP> group”, 第 9.2.2
節</A>),而將CVS用戶放在<SAMP>src</SAMP>用戶組(參閱<A
href="http://qref.sourceforge.net/Debian/reference/ch-vcs.zh-cn.html#s-cvs">CVS,
第 12.1 節</A>)。
<P>用<CODE>adduser</CODE>,<CODE>addgroup</CODE>,<CODE>vipw</CODE>,<CODE>vipw
-s</CODE>,<CODE>vigr</CODE>,以及<CODE>vigr -s</CODE>檢查一下用戶及用戶組是否配置得當。
<HR>
<A name=s4.2.3></A>
<H3>4.2.3 如何關機</H3>
<P>和其它現代操作系統一樣,系統的工作文件均緩存于內存,所以在切斷電源之前Linux需要完成特別的關機程序。下面就是多用戶模式下使用的關機命令: <PRE> # shutdown -h now
</PRE>
<P>這是單用戶模式下使用的關機命令: <PRE> # poweroff -i -f
</PRE>
<P>等待屏幕上顯示“System halted”字樣之后切斷電源。如果在BIOS和Linux中開啟了apm,系統會自動切斷電源。詳情參閱<A
href="http://qref.sourceforge.net/Debian/reference/ch-install.zh-cn.html#s-apm">多內存和關機自動斷電,
第 3.7.4 節</A>。
<HR>
<A name=s4.2.4></A>
<H3>4.2.4 命令行編輯</H3>
<P><CODE>bash</CODE>是默認shell,它能記住使用過的命令。只需按up-arrow鍵就能進入記憶模式,使用上下箭頭找你想輸入的命令。其它需要牢記的重要擊鍵有:
<PRE> Ctrl-U: 刪除行首到光標間的內容
Ctrl-D: 中止輸入
Lt-click-and-drag-mouse: 選擇并拷貝到剪貼板(gpm)
Ctrl-click-mouse: 將剪貼板內容粘貼到光標處(gpm)
</PRE>
<P>對于常規Linux系統控制臺,上述命令中通常指的是左邊的<SAMP>Ctrl</SAMP>和<SAMP>Alt</SAMP>鍵。
<HR>
<A name=s4.2.5></A>
<H3>4.2.5 執行命令</H3>
<P>典型的命令執行方法是使用如下shell命令行序列: <PRE> $ LC_ALL=fr ls -la
</PRE>
<P>在此,<CODE>ls</CODE>程序在前臺執行環境變量<SAMP>LC_ALL</SAMP>設置為<SAMP>fr</SAMP> Here,
program <CODE>ls</CODE> is executed in the foreground job with the environment
variable <SAMP>LC_ALL</SAMP> set to <SAMP>fr</SAMP> for French and the command
line argument set to <SAMP>-la</SAMP> for listing everything in detail. If the
command line is post-fixed by <SAMP>&</SAMP> sign then the command is
executed in the background job. The background job allows user to run multiple
programs in a single shell.
<P>The execution of the command can be managed by following key strokes. <PRE> Ctrl-C: 中止程序
Ctrl-Z: 暫停程序
Ctrl-S: 停止屏幕輸出
Ctrl-Q: 恢復屏幕輸出
Ctrl-Alt-Del: 重啟/關閉系統(參閱/etc/inittab)
</PRE>
<P>有關如何管理程序運行,可參閱<CODE>bash(1)</CODE>中的<SAMP>jobs</SAMP>、<SAMP>fg</SAMP>、<SAMP>bg</SAMP>和<SAMP>kill</SAMP>。
<HR>
<A name=s4.2.6></A>
<H3>4.2.6 需要牢記的基本命令</H3>
<P>下列是最基本的Unix命令: <PRE> ls, ls -al, ls -d, pwd, cd, cd ~user, cd -,
cat /etc/passwd, less, bg, fg, kill, killall,
uname -a, type <VAR>commandname</VAR>, sync, netstat,
ping, traceroute, top, vi, ps aux, tar, zcat,
grep, ifconfig, ...
</PRE>
<P>在命令提示符后輸入<SAMP>man</SAMP>或<SAMP>info</SAMP>加相關命令名,可查看該命令的意思。許多Linux命令可使用下列調用獲得簡要幫助信息:
<PRE> $ commandname --help
$ commandname -h
</PRE>
<P><SAMP>whatis <EM>commandname</EM></SAMP>可以顯示任何命令的單行概述,這些內容來自于相關幫助文件的開頭。
<HR>
<A name=s4.2.7></A>
<H3>4.2.7 X Window系統</H3>
<P>從控制臺啟動X Window系統: <PRE> # exec startx
</PRE>
<P>右鍵點擊root窗口可以喚出選擇菜單。
<HR>
<A name=s4.2.8></A>
<H3>4.2.8 重要鍵盤命令</H3>
<P>可在Linux控制臺中使用的重要擊鍵(<SAMP>plus</SAMP>、<SAMP>minus</SAMP>指數字鍵盤上的按鍵): <PRE> Alt-F1 thru F6: 切換到其它偽終端
Ctrl-Alt-F1 thru F6: 切換到其它偽終端
(在X-window、DOSEMU等運行環境中)
Alt-F7: 切換回X-window
Ctrl-Alt-minus: 降低X-window的顯示分辯率
Ctrl-Alt-plus: 提高X-window的顯示分辯率
Ctrl-Alt-Backspace: 中止X-windows
Alt-X, Alt-C, Alt-V: 通用的Windows/Mac剪切、拷貝、粘貼鍵
在某些程序如Netscape Composer中,組合鍵中的Ctrl鍵換成了Alt鍵
</PRE>
<HR>
<A name=s-mc></A>
<H2>4.3 Midnight Commander (MC)</H2>
<P>Midnight Commander (MC)是Linux控制臺和其它終端環境中的GNU“瑞士軍刀”。
<HR>
<A name=s4.3.1></A>
<H3>4.3.1 安裝MC</H3><PRE> # apt-get install mc
</PRE>
<P>接著按照其手冊頁面<CODE>mc(1)</CODE>中描述的方法修改<CODE>~/.bashrc</CODE>(或<CODE>/etc/bash.bashrc</CODE>,
<CODE>.bashrc</CODE>會調用它),打開<SAMP>-P</SAMP>選項,這使得MC不必退出就能更改其工作目錄。
<P>如果處于<CODE>kon</CODE>或<CODE>Kterm</CODE> for
Japanese等使用某些圖形特性的終端,MC運行會出一些問題,可在MC命令行中加上<SAMP>-a</SAMP>加以預防。
<HR>
<A name=s4.3.2></A>
<H3>4.3.2 啟動MC</H3><PRE> $ mc
</PRE>
<P>在MC中用戶可輕而易舉使用菜單完成所有的文件操作。
<HR>
<A name=s4.3.3></A>
<H3>4.3.3 文件管理器</H3>
<P>默認狀態下,所有文件列于兩個目錄面板。一種實用的方式是將右邊窗口設定為“information”,用來查看文件訪問權限等信息。下面是一些基本的擊鍵。如果<CODE>gpm</CODE>
daemon在運行,你還可以使用鼠標。(在MC中進行剪切和粘貼操作時另忘了按下shift鍵。)
<UL>
<LI><SAMP>F1</SAMP>: 幫助菜單
<LI><SAMP>F3</SAMP>: 內置文件閱讀器
<LI><SAMP>F4</SAMP>: 內置編輯器
<LI><SAMP>F9</SAMP>: 激活折疊菜單
<LI><SAMP>F10</SAMP>: 退出Midnight Commander
<LI><SAMP>Tab</SAMP>: 在兩個窗口間移動
<LI><SAMP>Insert</SAMP>: 為多文件操作生成文件如拷貝
<LI><SAMP>Del</SAMP>: 刪除文件(小心—請設置MC為安裝刪除模式)
<LI>Cursor keys: 與各自的名字一致 </LI></UL>
<HR>
<A name=s4.3.4></A>
<H3>4.3.4 命令行技巧</H3>
<UL>
<LI><CODE>cd</CODE>命令可改變焦點屏幕中的目錄位置。 </LI></UL>
<UL>
<LI><SAMP>Control-Enter</SAMP>或<SAMP>Alt-Enter</SAMP>可以將文件名拷貝到命令行。在編輯命令行時可與<CODE>cp</CODE>或<CODE>mv</CODE>命令結合使用。
</LI></UL>
<UL>
<LI><SAMP>Alt-Tab</SAMP>顯示焦點文件所屬文件或目錄的文件名 </LI></UL>
<UL>
<LI>可指定MC兩個目錄窗口的起始目錄;例如<SAMP>mc /etc /root</SAMP>。 </LI></UL>
<UL>
<LI><SAMP>Esc</SAMP> + <VAR>numberkey</VAR> == <SAMP>F<VAR>n</VAR></SAMP>
(例如<SAMP>Esc</SAMP> + <SAMP>1</SAMP> = <SAMP>F1</SAMP>, etc.; <SAMP>Esc</SAMP>
+ <SAMP>0</SAMP> = <SAMP>F10</SAMP>) </LI></UL>
<UL>
<LI><SAMP>Esc</SAMP> key == <SAMP>Alt</SAMP> key (= <SAMP>Meta</SAMP>,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -