1. 程式人生 > 其它 >在Linux中獲得幫助說明和檢視使用者手冊

在Linux中獲得幫助說明和檢視使用者手冊

技術標籤:Linuxhelpman

文章目錄

在Linux中獲得幫助說明和檢視使用者手冊

獲取幫助說明

如果知道命令的名稱,獲取幫助說明最簡單的方法是:

<command> --help

比如:

fdisk --help

檢視使用者手冊

有時候<command> --help 提供的資訊太過簡略,可以通過man命令檢視該命令的使用者手冊(manual)。

# 檢視命令的使用者手冊
man <command>

# 示例
man
fdisk # 上下鍵逐行檢視 # 空格鍵翻頁 # 搜尋的用法和vi類似 # q 退出

還可以通過man <section> <command> 檢視該命令的使用者手冊的某個章節(section)。

# fdisk(8) 檢視該命令使用者手冊的第8章
# 8   System administration commands (usually only for root)
man 8 fdisk

執行man man 可以看到使用者手冊的章節說明:

1   Executable programs or shell commands
2   System calls (
functions provided by the kernel) 3 Library calls (functions within program libraries) 4 Special files (usually found in /dev) 5 File formats and conventions eg /etc/passwd 6 Games 7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) 8 System administration commands (
usually only for root) 9 Kernel routines [Non standard]

如果想看某個命令都有哪些章節,執行man -f <command>

示例:

man -f passwd

在使用者手冊中搜索

如果想執行某個操作,但是不知道具體的命令名稱,可以用man -k <keyword> 來用關鍵字搜尋。

示例:

man -k firewall
man -k 'change root'
man -k 'partition'

Troubleshooting

Q1: 執行man -f 時報錯“man: can’t set the locale; make sure LC_* and LANG are correct”。

A1: 在~/.bashrc中新增以下內容,再執行source ~/.bashrc

export LANG=en_US.utf-8
export LC_ALL=en_US.utf-8

Q2: 執行man -k 時,無論搜尋什麼關鍵字都提示"nothing appropriate"。

A2:執行mandb 重建man索引。