M20 – 1- 第二周博客(1):幫助手冊查詢的使用

Linux系統中存在諸多的命令,而這些命令分為內鍵命令和外部命令。如何查詢命令屬于內部還是外部呢。前一篇博客已經介紹type命令,type命令可以區分命令屬于內部還是外部,下面舉個例子:

blob.png

為什么這一期博客還重復講如何區分內部與外部命令呢,因為在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: 管理類的命令

blob.png

3.2、man命令的配置文件

man命令的配置文件:/etc/man.config
平常在安裝某些程序的時候,程序自身也自帶man手冊,安裝完程序后,不但要對該程序的自身命令做環境變量,也要對做的環境變量設置man手冊,如何配置該程序的命令man手冊呢,直接在
man的配置文件中添加該程序的man路徑即可。如下圖:

blob.png

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

(0)
AleenAleen
上一篇 2016-08-02 16:50
下一篇 2016-08-02 19:14

相關推薦

  • N25_第六周作業

    1、復制/etc/rc.d/rc.sysinit文件至tmp目錄,將/tmp/rc.sysinit文件中的以至少一個空白字符開頭的行的行首加#; :%s@^[[:space:]]\+@#&@g(CentOS7下并未看到這個文件) 2、復制/boot/grub/grub.conf至/tmp目錄中,刪除/tmp/grub.conf文件中的行首的空白字符;…

    Linux干貨 2017-02-15
  • LVM基礎

    邏輯卷的原理 邏輯卷的組成上包括物理卷,邏輯組,邏輯卷 物理卷即是磁盤分區或者塊設備經過轉換以后形成的抽象的邏輯設備 邏輯組即是將物理卷進行統一打包,合成一個更大的邏輯上的分區 邏輯卷是在邏輯組的基礎上細分的課動態調節的虛擬磁盤分 其工作原理是通過某種機制將物理上的塊設備或者分區抽象的進行封裝,然后以邏輯卷的方式統一呈現給 上層的應用 邏輯卷的操作 一:創建…

    2017-05-01
  • 加油吧!少年!—至我和我M25期的伙伴

    引用 衣帶漸寬終不悔,為伊消得人憔悴。—王國維《人間詞話》 轉眼已到了27歲的年紀,不知道自己是否還稱得上少年。公交上讓座被小朋友成為叔叔也都是很多年的事了。哪怕再有一顆少年心現在也要肩負起整個家庭的責任。 從畢業已工作了將近六個年頭,無聊的工作平凡的薪水已經使我厭倦。閉上眼睛以后需要贍養四個老人,還要照顧孩子以后這些難題映入腦海。曾經以為遙遠的…

    Linux干貨 2017-07-11
  • 初識selinux

    一、selinux介紹     1.selinux歷史     SELinux: Secure Enhanced Linux,是美國國家安全局「NSA=The National Security Agency」和SCC(Secure Computing Corporation)開…

    Linux干貨 2016-09-21
  • Week9’s homework

    Week9's homework 1、寫一個腳本(1)判斷當前系統上所有用戶的shell是否為可登錄shell(即用戶的shell不是/sbin/nologin)(2)分別統計兩類用戶的個數;通過字符串比較來實現。 #!/bin/bash # for i in $(cat /etc/passwd |…

    Linux干貨 2016-12-24
  • 高考作業

    1、簡述TCP三次握手四次揮手過程及各過程中客戶端和服務器端的狀態。 TCP三路握手,作用為完成三次握手,主機A與主機B開始傳送數據。 第一次握手:客戶端A(狀態為SYN_SEND)發送位碼為syn=1,隨機產生seq number=1234567的數據包到服務器,服務器B(狀態為LISTEN)由SYN=1知道,客戶端A要求建立聯機; 第二次握手:服務器B(…

    Linux干貨 2016-06-22
欧美性久久久久