Red Hat Linux Essentials Unit 3 - Running Commands and Getting Help
學習目標
- 正確地執行指令
- 正確地讀出一行指令的意義
- 使用線上 help 資源
Running Commands
1.指令的syntax: commond options arguments
commond: 命令本身
options: 處理行為,做什麼事,通常前置字元 - or +
arguments: 處理的對像
2.指令的每個項目都要用空白格開
3.options 分 Single-letter 與 Full-word
Single-letter 表示 -a -b -c 可以合併 -abc 使用
Full-letter 全名的 option,唯一,不可合併使用,ex: --help
3.Arguments 通常是處理對像,可能是檔案名稱,或者目錄名稱
4.分號 " ; " 可以接續多個指令,ex: # sync;sync;reboot
5.Ctrl+C 可中斷執行中指令
一些簡單的指令
1.date,顯示日期指令,ex: # date +"%Y%m%d"
20070514
2.cal,顯示月曆指令,ex: # cal 9 2010

Getting Help1.要善用線上的manual,不要試圖記下所有指令
2.線上 help 指令資源:
格式表示法:
[] 中括號表示,可有可無
<> 要替換適當文字,ex: <username>
x|y|z,多選一,表示 x or y or z
-abc,表示合併 -a,-b,-c
...,表示可以重覆出現,ex: filename...
3.
whaitis,使用whatis db,建立資料庫指令
makewhatis,模糊比對指令
apropos,ex: # whatis cal、# apropos passwd

4.
commond --help,ex: # passwd --help

5.
man [<chapter>] <command>,ex: # man ls、man 5 passwd
man page 有分 chapter 不同 chapter 代表的功能導向,1.User commands 2.System calls 3.Library calls 4.Special files 5.File formats 6.Games 7.Miscellaneous 8.Administrative commands
設定檔格式: 5
開發人員: 2,3,4
最常用: 1,5,8
當在看 man page 時,
PgUP,PgDn,向上鍵,向下鍵,可以捲動頁面
/ 向下找關鍵字,
? 向上找關鍵字,
n 順向找下一個關鍵字,
N 逆向找下一個關鍵字,
n/N 會隨著使用
/ 或
? 而有不同的找尋方向,
q 離開,ex: /
text
模糊比對指令,
man -k,使用 whatis db,其實它指令等於
apropos
6.
info,比man 更詳細,ex: info passwd、info
改進用 link 的方式,樹狀結構,每一個page 的
* 號為 link,
PgUp,PgDn 翻頁,
tab 可以跳下一個 link,
Enter 進入 link,
u 往上一層,
n 往同層的下一個page,
p 往同層的上一個page,
s 找尋關鍵字,若要找下一個關鍵字需要再次按
s,
q 離開
7./usr/share/doc/,有很詳細的說明文件、授權內容,格式包含 HTML/PDF/PS,也有可能是整本書的電子檔
8.Red Hat Documention,官方網站或者Docs CD/DVD
Lab 3 重點
1.man -f = whatis
2.man -k,模糊搜尋
3.man -K(大寫K),找尋原始完整的文件,會問你是不是要解開觀看,ex: # man -K ls
/usr/kerberos/man/man8/klogind.8.gz? [ynq]
4.找尋 basename function of the C programming language,man 3 basename
5.列出長列式 long listing 以及 human-readable size
ex:
# ls -lh
drwx------ 2 root root 4.0K 4月 9 20:38 Mail
- rw-r--r-- 1 root root 9.7M 4月 22 13:09 moodle-latest-18.tgz
6. -x|-y → -y
[-abcde] → -abc
Filename... → one.txt two.txt
7.利用# man issue,知道 escape characters 要依照 mingetty 格式表示
8.# man mingetty,使用 / 找關鍵字"hostname",找到 hostname 的表示法 \n
9.# nano /etc/issue,加上 \n,登出登入,測試是否有設定成功