linux查看帮助信息,命令帮助信息的获取
獲取命令的的獲取
Linux中命令分為內(nèi)建命令和外部命令,內(nèi)建命令是shell自帶的命令。在獲取命令幫助信息時,先確定命令是內(nèi)建命令還是外部命令,使用type命令,可以查看命令的類型。外部命令獲取幫助信息有以下幾種方式:
使用命令自帶的簡要格式的使用幫助
使用man幫助文檔手冊,用man命令查看
使用info command獲取命令的在線文檔
查看應(yīng)用程序自帶的幫助文檔:/usr/share/doc/command-VERSION
主流發(fā)行版官方文檔
程序官方文檔
type:
語法
type command
實例
內(nèi)建命令
[root@localhost ~]# type echo
echo 是 shell 內(nèi)嵌
外部命令
[root@localhost ~]# type wc
wc 是 /usr/bin/wc
內(nèi)建命令獲取幫助
內(nèi)建命令獲取幫助信息使用用help命令
命令格式:
~]#help command
實例:
[root@localhost ~]# help cd
cd: cd [-L|[-P [-e]]] [dir]
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.
The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.
If the directory is not found, and the shell option `cdable_vars’ is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.
Options:
-L force symbolic links to be followed
-P use the physical directory structure without following symbolic
links
-e if the -P option is supplied, and the current working directory
cannot be determined successfully, exit with a non-zero status
The default is to follow symbolic links, as if `-L’ were specified.
Exit Status:
Returns 0 if the directory is changed, and if $PWD is set successfully when
-P is used; non-zero otherwise.
外部命令使用幫助
1. 命令自帶的簡要個格式使用幫助
語法
COMMAND –help
實例
[root@localhost ~]# wc –help
用法:wc [選項]… [文件]…
或:wc [選項]… –files0-from=F
Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. With no FILE, or when FILE is -,
read standard input. A word is a non-zero-length sequence of characters
delimited by white space.
The options below may be used to select which counts are printed, always in
the following order: newline, word, character, byte, maximum line length.
-c, –bytes print the byte counts
-m, –chars print the character counts
-l, –lines print the newline counts
–files0-from=文件 從指定文件讀取以NUL 終止的名稱,如果該文件被
指定為”-“則從標(biāo)準(zhǔn)輸入讀文件名
-L, –max-line-length 顯示最長行的長度
-w, –words 顯示單詞計數(shù)
–help 顯示此幫助信息并退出
–version 顯示版本信息并退出
GNU coreutils online help:
請向 報告wc 的翻譯錯誤
要獲取完整文檔,請運行:info coreutils ‘wc invocation’
2. manual幫助文檔手冊
man命令是Linux下的幫助指令,通過man指令可以查看Linux中的指令幫助、配置文件幫助和編程幫助等信息。幫助文檔手冊存放在/usr/share/man目錄下。
語法
man COMMAND
查看指定#章節(jié)幫助
man # COMMAND
選項
-a:在所有的man幫助手冊中搜索
-f:等價于
-P:指定內(nèi)容時使用分頁程序;
-M:指定man手冊搜索的路徑。
章節(jié)
1 Executable programs or shell commands用戶命令章節(jié),所有使用戶都可以使用
2 System calls (functions provided by the kernel)系統(tǒng)調(diào)用命令章節(jié)(由內(nèi)核提供的函數(shù));
3 Library calls (functions within program libraries)c庫調(diào)用章節(jié)(由庫程序提供的函數(shù));
4 Special files (usually found in /dev)設(shè)備及特殊文件幫助文檔;
5 File formats and conventions eg /etc/passwd配置文件的格式及相關(guān)參數(shù);
6 Games 游戲幫助文檔;
7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)雜項幫助文檔;
8 System administration commands (usually only for root)系統(tǒng)管理命令使用幫助文檔;
9 Kernel routines [Non standard]內(nèi)核程序代碼的幫助文檔;
手冊各部分功能
NAME:命令名稱及功能說明
SYNOPSIS:命令使用格式摘要;
DESCRIPTION:詳細描述信息;
OPTIONS:選項詳細說明;
AUTHOR:作者;
BUGS:報告程序bug的途徑;
EXAMPLES:使用示例;
SEE ALSO:額外參考;
FILES:相關(guān)配置文件
manual手冊中部分符號的意義:
[]:表示該符號內(nèi)的內(nèi)容為可選內(nèi)容
<>:表示該符號內(nèi)的內(nèi)容為必選內(nèi)容
a|b|c:多選一
…:同類內(nèi)容可出現(xiàn)多次
man page手冊頁操作方法:
手冊頁man page是用less程序來查看的,可以方便地使屏幕上翻和下翻, 所以在man page里可以使用less的所有選項。
快捷鍵
空格鍵:項文件尾翻一屏
b:項文件首部翻一屏
ctrl+d:向文件尾部翻半屏
ctrl+u:向文件首部翻半屏
回車鍵:向文件尾部翻一行
k:向文件首部翻一行
G:跳轉(zhuǎn)至最后一行
q:quit,退出
末行輸入:
#G(末行模式下輸入):跳轉(zhuǎn)至指定的#行
1G(末行模式下輸入):跳轉(zhuǎn)至文件首部
/keyword:從文件首部向文件尾部依次查找,不區(qū)分大小寫
?keyword:從文件尾部向文件首部依次查找
實例
查看wc命令幫助信息
[root@localhost ~]# man wc
查看sleep第3章節(jié)的幫助信息
[root@localhost ~]# whatis sleep
sleep (1) – 延遲指定數(shù)量的時間
sleep (3) – sleep for the specified number of seconds
sleep (1p) – suspend execution for an interval
sleep (3p) – suspend execution for an interval of time
[root@localhost ~]# man 3 sleep
本文來自投稿,不代表Linux運維部落立場,如若轉(zhuǎn)載,請注明出處:http://www.178linux.com/105081
總結(jié)
以上是生活随笔為你收集整理的linux查看帮助信息,命令帮助信息的获取的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 论曾文正公创业门道
- 下一篇: C语言实现辗转相除法计算两数最大公约数