忘記指令名稱但記得功能關鍵字時,apropos (等同 man -k) 能快速搜尋 man page 簡短描述,找到所需指令。本文說明語法、輸出欄位解讀與實用技巧。
apropos 關鍵字
man -k 關鍵字 # 完全相同
apropos -e 關鍵字 # 精確匹配關鍵字 (不做部分匹配)
apropos -r '正則' # 正則表達式搜尋
apropos -s 1,5 關鍵字 # 限定 man 章節 (1=用戶指令, 5=設定檔)
$ apropos who
at.allow [at] (5) - determine who can submit jobs via at or batch
at.deny [at] (5) - determine who can submit jobs via at or batch
jwhois (1) - client for the whois service
who (1) - show who is logged on
whoami (1) - print effective userid
man 指令名 閱讀完整手冊。apropos network | lessapropos -l keyword | cut -d' ' -f1apropos -s 5 passwd → passwd (5) - password filemandb (或 /etc/cron.daily/man-db 自動執行),新安裝套件後若搜不到請手動執行。| 章節 | 內容 | 範例 |
|---|---|---|
| 1 | 用戶指令 | ls, cp, systemctl |
| 2 | 系統呼叫 | open, read, fork |
| 3 | 庫函式 | printf, malloc, pthread_create |
| 4 | 特殊檔案 (裝置) | null, tty, random |
| 5 | 設定檔格式 | passwd, fstab, sshd_config |
| 7 | 慣例與宏套件 | man, glob, regex |
| 8 | 系統管理指令 | mkfs, fdisk, useradd |
apropos 是「不知道指令名」時的最佳入口。養成「關鍵字 → apropos → man 細讀」習慣,能大幅縮短查閱文檔時間。