在 Linux 上遇到不熟悉的指令,多數人直覺反應是 man。但有一類指令是 shell 自己內建的(例如 cd、pwd、echo、alias),它們沒有獨立的 man 頁面,這時就該請出 help。
本文整理自人民郵電出版社《Linux 命令應用大詞典》,該書收錄 729 個命令、1935 個實例,遇到卡住的參數直接翻查即可,很適合當案頭工具書。
help [選項] [命令]
| 選項 | 用途 |
|---|---|
| -d | 只顯示該命令簡短的主題描述 |
| -s | 只顯示該命令簡短的語法格式 |
[root@rhel ~]# help pwd pwd: pwd [-LP] Print the name of the current working directory. Options: -L print the value of $PWD if it names the current working directory -P print the physical directory, without any symbolic links By default, `pwd' behaves as if `-L' were specified. Exit Status: Returns 0 unless an invalid option is given or the current directory cannot be read.
[root@rhel ~]# help -s pwd pwd: pwd [-LP]
[root@rhel ~]# help -d pwd pwd - Print the name of the current working directory.
三者定位不同:help 針對 shell 內建指令,輸出精簡;man 是萬用說明手冊,涵蓋絕大多數外部程式與設定檔;info 則提供章節式的完整文件,可跳轉閱讀。搭配使用,例如 help cd 加上 man bash,幾乎能解決所有語法疑問。
小技巧:若想一次瀏覽某個內建指令的所有說明,可以不加任何選項直接執行 help 指令名;若想列出全部內建指令,直接輸入 help 即可。
本文出自「airfish2000」部落格,請務必保留此出處 https://airfish2000.blog.51cto.com/10829608/1871365