Linux系統中存在諸多的命令,而這些命令分為內鍵命令和外部命令。如何查詢命令屬于內部還是外部呢。前一篇博客已經介紹type命令,type命令可以區分命令屬于內部還是外部,下面舉個例子:
為什么這一期博客還重復講如何區分內部與外部命令呢,因為在man手冊查詢中,內部命令并不是使用man查詢幫助手冊,僅僅使用與外部命令,那內鍵命令如何查詢呢,接下來要講的就是help命令,help命令是用于查詢內鍵命令的。
Linux命令的幫助查詢以及獲取
1、內鍵命令幫助手冊查詢
help命令
簡介: Display information about builtin commands.
格式: help [-dms] [pattern ...]
實例1: [root@centos6 ~]# help cd #cd為內鍵命令,因此用help命令查詢,可獲取cd的幫助手冊 cd: cd [-L|-P] [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 The default is to follow symbolic links, as if `-L' were specified. Exit Status: Returns 0 if the directory is changed; non-zero otherwise.
2、外部命令幫助手冊查詢
man命令
簡介: man - an interface to the on-line reference manuals
格式: man COMMAND
實例1: [root@centos6 ~]# type ifconfig ifconfig is /sbin/ifconfig [root@centos6 ~]# man ifconfig IFCONFIG(8) Linux Programmer’s Manual IFCONFIG(8) NAME ifconfig - configure a network interface SYNOPSIS ifconfig [interface] ifconfig interface [aftype] options | address ... NOTE This program is obsolete! For replacement check ip addr and ip link. For statistics use ip -s link.
3、man幫助手冊中的段落說明
3.1、man手冊頁
man手冊頁包含:man1..man8,、 分別講的是(1)man1: 用戶命令、man2: 系統調用、man3: C庫調用、man4: 設備文件及特殊文件、man5: 配置文件格式、man6: 游戲、man7: 雜項、man8: 管理類的命令
3.2、man命令的配置文件
man命令的配置文件:/etc/man.config 平常在安裝某些程序的時候,程序自身也自帶man手冊,安裝完程序后,不但要對該程序的自身命令做環境變量,也要對做的環境變量設置man手冊,如何配置該程序的命令man手冊呢,直接在 man的配置文件中添加該程序的man路徑即可。如下圖:
3.3、幫助手冊中的段落說明
NAME //名稱 SYNOPSIS //簡介 DESCRIPTION //描述 OPTIONS //選項 EXAMPLES //實例 AUTHOR //作者 REPORTING BUGS //錯誤報告 SEE ALSO //參見
而SYNOPSIS中可分為 []:可選的內容 <>: 必選的內容 a|b:二選一 ...: 同一內容可出現多次
3.4、man命令查詢的操作方法
(1)翻頁查詢:
Space, ^V, ^f, ^F: 向文件尾翻屏; b, ^B: 向文件首部翻屏; d, ^D: 向文件尾部翻半屏; u, ^U: 向文件首部翻半屏; RETURN, ^N, e, ^E or j or ^J: 向文件尾部翻一行; y or ^Y or ^P or k or ^K: 向文件首部翻一行; q: 退出;
(2)跳轉查詢:
1G: 回到文件首部 G: 翻至文件尾部
(3)文本搜索:
KEYWORD: 以KEYWORD指定的字符串為關鍵字,從當前位置向文件尾部搜索;不區分字符大小寫; n: 下一個 N:上一個 ?KEYWORD: 以KEYWORD指定的字符串為關鍵字,從當前位置向文件首部搜索;不區分字符大小寫; n: 跟搜索命令同方向,下一個 N:跟搜索命令反方向,上一個
4、info命令
簡介: info - read Info documents
格式: info [OPTION]... [MENU-ITEM...]
[root@centos6 ~]# type info #info命令屬于外部命令 info is /usr/bin/info [root@centos6 ~]# info ifconfig #info命令也可以查詢外部命令的幫助手冊,且比man命令的詳解更簡潔 File: *manpages*, Node: ifconfig, Up: (dir) IFCONFIG(8) Linux Programmer’s Manual IFCONFIG(8) NAME ifconfig - configure a network interface SYNOPSIS ifconfig [interface] ifconfig interface [aftype] options | address ... NOTE This program is obsolete! For replacement check ip addr and ip link. For statistics use ip -s link. DESCRIPTION Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.
info命令查詢的操作方法
方向鍵: PgUp,PgDn 導航 Tab鍵: 移動到下一個鏈接 d: 顯示主題目錄 Home: 顯示主題首部 Enter: 進入選定鏈接 n/p/u/l: 進入下/前/上一層/最后一個鏈接 s: 文字文本搜索 q: 退出info
5、利用網絡資源查詢命令的使用
(1)http://www.redhat.com/docs (2)http://os.51cto.com/linuxman/ (3)seo搜索引擎查詢,Google、baidu
原創文章,作者:Aleen,如若轉載,請注明出處:http://www.www58058.com/26852