Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Linux man 命令詳解:線上手冊查詢、區段導航、配置檔與顯示器自定義

編輯:Linux 系統常見問題解答

man 是什麼

man (Manual) 是 Linux 系統內建的線上參考手冊閱讀器,提供命令、系統呼叫、庫函數、檔案格式、協定、裝置等標準化文檔。

命令語法

man [選項] [區段] 關鍵字...

常用選項

手冊區段 (Section) 速查

選項說明
-a顯示所有匹配的手冊頁 (預設只顯第一個)
-f / --whatis顯示一行簡短描述 (等同 whatis)
-k / --apropos搜尋描述中包含關鍵字的頁面 (等同 apropos)
-K全文搜尋所有手冊頁 (較慢)
-w / --where / --path僅輸出手冊頁檔案路徑,不顯示內容
-C file指定配置檔 (預設 /etc/man.config)
-M path指定手冊頁搜尋路徑 (冒號分隔)
-P pager指定顯示器 (預設 /usr/bin/less -isR)
-S list指定搜尋區段順序 (分號分隔,如 2;3;1)
-c重新格式化快取
-d除錯模式:顯示搜尋過程不顯示內容
-h顯示幫助

指定區段:man 3 printf (查庫函數而非命令)。

閱讀器 (less) 常用快捷鍵

  • Space 下一頁、b 上一頁
  • /keyword 向下搜尋、?keyword 向上搜尋、n 下一個、N 上一個
  • g 首頁、G 尾頁
  • q 退出

配置檔 /etc/man.config (man_db.conf) 關鍵設定

  • MANPATH 手冊頁搜尋路徑
  • PAGER 預設顯示器
  • MANSECT 預設區段搜尋順序
  • DEFINE 定義預設選項

實用技巧

  • man -k keyword 快速找相關命令
  • man -w ls 獲取手冊頁路徑供腳本使用
  • man --html=firefox ls 以瀏覽器閱讀 (需支援)
  • 環境變數 MANPAGER、MANWIDTH 控制顯示行為

總結

man 是 Linux 工程師最忠實的隨身導師。熟練使用區段導航、關鍵字搜尋 (-k)、顯示器自定義,能在無網絡環境下高效獲取權威資訊。養成「先 man 再問」的習慣,可避免 80% 的低級錯誤。

Copyright © Windows教程網 All Rights Reserved
區段內容範例
1使用者命令ls, cp, grep
2系統呼叫open, read, fork
3庫函數printf, malloc, pthread_create
4裝置檔案null, tty, random
5檔案格式/配置passwd, fstab, sshd_config
6遊戲fortune
7慣例/協定/宏套件man, glob, regex, ascii
8系統管理命令mount, fdisk, systemctl
9核心內部函數內核開發參考