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

相关推荐

  • Linux系统的文件管理命令及bash的相关工作特性

    熟悉Linux系统的文件管理命令,了解bash的工作特性,加强练习并掌握其内容。

    2017-09-30
  • linux的基础小命令

    1、ifconfig,显示主机的IP地址 2、echo 用法echo [short-option]… [string]…     -n:不进行换行     string可以使用单引号或双引号引用变量,单引号变量内容不会替换,双引号会替换  &nb…

    Linux干货 2016-10-30
  • bash的基础特性[更新中]

    2、bash的工作特性之命令执行状态返回值和命令行展开所涉及的内容及其示例演示。
    3、请使用命令行展开功能来完成以下练习:
    (1)、创建/tmp目录下的:a_c, a_d, b_c, b_d
    (2)、创建/tmp/mylinux目录下的:
    mylinux/
    ├── bin
    ├── boot
    │   └── grub
    ├── dev
    ├── etc
    │   ├── rc.d
    │   │   └── init.d
    │   └── sysconfig
    │   └── network-scripts
    ├── lib
    │   └── modules
    ├── lib64
    ├── proc
    ├── sbin
    ├── sys
    ├── tmp
    ├── usr
    │   └── local
    │   ├── bin
    │   └── sbin
    └── var
    ├── lock
    ├── log
    └── run
    5、如何定义一个命令的别名,如何在命令中引用另一个命令的执行结果?
    6、显示/var目录下所有以l开头,以一个小写字母结尾,且中间至少出现一位数字(可以有其它字符)的文件或目录。
    7、显示/etc目录下,以任意一个数字开头,且以非数字结尾的文件或目录。
    8、显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录。
    9、在/tmp目录下创建以tfile开头,后跟当前日期和时间的文件,文件名形如:tfile-2016-05-27-09-32-22。
    10、复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。
    11、复制/etc目录下所有以.d结尾的文件或目录至/tmp/mytest2目录中。
    12、复制/etc/目录下所有以l或m或n开头,以.conf结尾的文件至/tmp/mytest3目录中。

    2018-03-17
  • linux基础之bash特性知识点

    1、 Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。     Linux 一切皆文件。个人理解 在linux下的命令操作都算是对文件操作     那么文件管理命令类命令可以分为下面几类     目录操作: &nbs…

    Linux干货 2016-09-24
  • 二、(2)bash的工作特性之:命令执行状态返回值及命令行展开

    bash 工作特性 命令执行状态 命令行展开

    2018-01-10
  • 网络配置——CentOS7

    CentOS 7 网络属性配置 使用传统命名方式: (1) 编辑/etc/default/grub 配置文件 GRUB_CMDLINE_LINUX ="rhgb quiet net.ifnames=0" 或:修改/boot/grub2/grub.cfg (2) 为grub2 生成其配置文件 grub2-mkconfig -o /etc/g…

    Linux干货 2016-09-11