Linux提供了豐富的幫助手冊,當你需要查看某個命令的參數時不必到處上網查找,只要man一下即可。
可以使用man man 查看man的使用方法
1.man共有以下幾個章節
代碼 | 功能 |
1 | 標準用戶命令(Executable programs or shell commands) |
2 | 系統調用(System calls)functions provided by the kernel |
3 | 庫調用(Library call)functions within program libraries |
4 | 特殊文件(設備文件)的訪問入口(/dev)Special files (usually found in /dev) |
5 | 文件格式(配置文件的語法),指定程序的運行特性 File formats and conventions |
6 | 遊戲(Games) |
7 | 雜項(Miscellaneous)including macro packages and conventions |
8 | 管理命令 System administration commands |
9 | 跟kernel有關的文件 Kernel routines |
2.man手冊的格式
NAME 命令名稱及功能簡要說明
SYNOPSIS 用法說明,包括可用的選項
DESCRIPTION 命令功能的詳細說明,可能包括每一個選項的意義
OPTIONS 說明每一項的意義
FILES 此命令相關的配置文件
BUGS
EXAMPLES 使用示例
SEE ALSO 另外參照
3.man手冊的使用方法
翻屏
向後翻一屏:space(空格鍵) 向前翻一屏:b
向後翻一行:Enter(回車鍵) 向前翻一行:k
查找:
/KEYWORD 向後查找 n:下一個
?KEYWORD 向前查找 N:前一個
退出:q
4.常用實例
分章節查看man的幫助手冊:
4.1 標準用戶命令
可以使用whatis命令是用於查詢一個命令執行什麼功能,並將查詢結果打印到終端上。
例如:
[root@nfs-server ~]#whatis cd
cd (1p) - change the working directory
cd [builtins] (1) - bash built-in commands, see bash(1)
#從上文的輸出結果我們看到cd命令是bash的內建命令,它的功能是改變當前目錄,可以在1和1p的章節中查看它的幫助。
[root@nfs-server ~]#man 1 cd
使用上面的命令可以直接查看cd的幫助信息。
[root@nfs-server ~]#man 1p cd
因爲1p章節是bash的幫助信息,所以在使用"man 1p cd"後,通過在man中輸入"/cd"查找相關的信息才能看到cd的幫助信息。
4.2 系統調用
[root@nfs-server]# whatis read
read (1p) - read a line from standard input
read (2) - read from a file descriptor
read (3p) - read from a file
read [builtins] (1) - bash built-in commands, see bash(1)
#從上面可看到,read在1,1p,2,3p中都有內容,下面查看系統調用
[root@nfs-server ~]#man 2 read
[root@nfs-server ~]#man 2 mount
4.3 庫調用
[root@nfs-server ~]# man 3 sleep
4.4 特殊文件(設備文件)
[root@nfs-server ~]#man 4 tty
4.5 文件格式(配置文件的語法)
[root@nfs-server ~]# man 5 passwd
4.8 管理命令
[root@nfs-server ~]# man 8 fdisk