首頁 > 軟體

Linux help命令:顯示命令的幫助資訊

2020-06-16 17:14:57

help 是非常簡單的命令,而且不經常使用。因為 help 只能獲取 Shell 內建命令的幫助,但在 Linux 中絕大多數命令是外部命令,所以 help 命令的作用非常有限。而且內建命令也可以使用 man 命令獲取幫助。

help 命令的基本資訊如下。

  • 命令名稱:help。
  • 英文原意:help。
  • 所在路徑:Shell 內建命令。
  • 執行許可權:所有使用者。
  • 功能描述:顯示 Shell 內建命令的幫助。


help 命令的格式非常簡單:

[root@localhost ~]# help 內建命令


Linux 中有哪些命令是內建命令呢?我們可以隨意使用 man 命令來査看一個內建命令的幫助,例如:

[root@localhost ~]# man help
BASH_BUILTINS(1)
BASH_BUILTINS(1)
NAME
bash,:,.,[, alias, bg, bind, break, builtin, caller, cd, command, compgen,complete, compopt, continue, declare, dirs, disown, echo, enable, eval, exec,exit, export,false, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout,mapfile, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt,source, suspend, test, times, trap, true, type, typeset, ulimit, umask,unalias, unset, wait - bash built-in commands, seebash(1)
...省略部分內容...
#這裡列出的命令就是所有的Shell內建命令

可以發現,如果使用 man 命令去査看任意一個 Shell 內建命令,則會列出所有 Shell 內建命令的幫助。査看一個具體的 Shell 內建命令如 history 的幫助,可以執行 "help history"。

如果我們使用 help 命令査看外部命令的幫助,則會如何呢?

[root@localhost ~]# help ls
-bash: help: no help topics match 'ls'.Try 'help help' or 'man -k Is' or 'info ls'.
#這裡會報錯,報錯資訊是"help無法得到 ls 命令的幫助,請査看 help 幫助,或者用 man 和 info 來査看ls的幫助資訊"

--help 選項

絕大多數命令都可以使用"--help"選項來査看幫助,這也是一種獲取幫助的方法。例如:

[root@localhost ~]# ls --help

這種方法非常簡單,輸出的幫助資訊基本上是 man 命令的資訊簡要版。


IT145.com E-mail:sddin#qq.com