Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux apropos 指令:以關鍵字搜尋 man page 的利器

編輯:Linux 教學

前言

忘記指令名稱但記得功能關鍵字時,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 指令名 閱讀完整手冊。
  • [別名]:同一 man page 的別名條目。
  • (章節號):man page 所屬章節 (1=一般指令, 2=系統呼叫, 3=庫函式, 4=特殊檔案, 5=設定檔格式, 7=慣例, 8=管理指令)。
  • -:分隔符,後接一行摘要說明。

進階技巧

  1. 配合 less 瀏覽大量結果:apropos network | less
  2. 只看指令名:apropos -l keyword | cut -d' ' -f1
  3. 搜尋設定檔格式:apropos -s 5 passwd → passwd (5) - password file
  4. 重建資料庫:mandb (或 /etc/cron.daily/man-db 自動執行),新安裝套件後若搜不到請手動執行。

man 章節速查

章節內容範例
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 細讀」習慣,能大幅縮短查閱文檔時間。

Copyright © Windows教程網 All Rights Reserved