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.178linux.com/26852

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

相关推荐

  • Python内置数据结构——集合set

    集合 定义 set翻译为集合 collection翻译为集合类型,是一个较大的概念 set是一个可变的、无序的、不重复的元素组成的集合 set的元素要求必须可以hash,目前已学的不可hash的类型只有list、set 元素不可以索引 set可以迭代 set的初始化 set_1 =set() #表示定义一个空集合set_1 set_1 =set(iterab…

    Linux干货 2017-10-03
  • 文件权限

    文件权限 文件属性       rw-r–r–表示文件权限     Root 表示文件所有者     Root 表示文件所属组     0 表示文件的大小 …

    Linux干货 2016-08-11
  • httpd服务归纳:浅谈I/O模型

    1. 四种理论的I/O模型      1) 调用者(服务进程):         阻塞:  进程发起I/O调用,如果调用为完成,进程被挂起休眠,不能再执行其他功能    …

    Linux干货 2015-05-27
  • 文本处理工具(练习+作业)

    文本处理工具(cut,sort,uniq)练习 1、找出ifconfig命令结果中本机的所有IPv4地址 [root@localhost ~]# ifconfig | tr -cs '[:digit:].' '\n'| sort -t. -k3 |tail -5 2、查出分区空间使用率的最大百分比值 [root@loc…

    Linux干货 2016-08-07
  • 2016/08/11:初涉shell脚本编程

    感悟 :    经过对文本处理工具grep,sed等内容的,以及vim文本编辑器的学习,马不停蹄的又进行了对shell脚本的学习。对shell脚本的认识是可以保存在本地,用的时候只要执行相关脚本,简短的命令就可以完成操作,可以用来应对日常重复性工作,有效提高系统管理员的效率,避免在重复性工作上花费不必要的时间。 *************…

    Linux干货 2016-08-16