SpongeBob

人生三种境界:昨夜西风凋碧树,独上高楼,望尽天涯路。 衣带渐宽终不悔,为伊消得人憔悴。 众里寻他千百度,蓦然回首,那人却在灯火阑珊处。
扩大
缩小

Linux下帮助使用方法

 

         作为Linux系统的初学者来说,学会使用获取帮助命令是非常重要的。我在接下来的文章里面总结了一些常用的获取帮助资料的方法,希望在以后可以帮到你。

 

一.whatis的使用

          whatis:用于查询一个命令执行什么功能,并将执行结果打印到终端上
         

[root@contos7 ~]# whatis ls
ls (1) - list directory contents
ls (1p) - list directory contents

 

         1. 基于数据库的查找
                  优点:查找速度快
                  缺点:没有实时性
           2.数据库文件
                  Centos6:/var/cache/man/whatis
                  Centos7:/var/cache/man/index.db
           3.更新数据库文件
                  Centos6:makewhatis
                  Centos7:mandb

  

二.help的使用

            help:用于显示shell内部命令的帮助信息。help命令只能显示shell内部的命令帮助信息。而对于外部命令的帮助信息只能使用man或者info命令查看。在使用之前可以用type命令查看一下命令的类型,参考不同用法。用法:type command 如果输出 XXX is a shell builtin 则是内部命令 , 其它输出则是外部命令。

             1.外部命令:
                        command –help 或command -h

                 

[root@contos7 ~]# date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

Mandatory arguments to long options are mandatory for short options too.
  -d, --date=STRING         display time described by STRING, not 'now'
  -f, --file=DATEFILE       like --date once for each line of DATEFILE
  -I[TIMESPEC], --iso-8601[=TIMESPEC]  output date/time in ISO 8601 format.
                            TIMESPEC='date' for date only (the default),
                            'hours', 'minutes', 'seconds', or 'ns' for date
                            and time to the indicated precision.
  -r, --reference=FILE      display the last modification time of FILE
  -R, --rfc-2822            output date and time in RFC 2822 format.
                            Example: Mon, 07 Aug 2006 12:34:56 -0600
      --rfc-3339=TIMESPEC   output date and time in RFC 3339 format.
                            TIMESPEC='date', 'seconds', or 'ns' for
                            date and time to the indicated precision.
                            Date and time components are separated by
                            a single space: 2006-08-07 12:34:56-06:00
  -s, --set=STRING          set time described by STRING
  -u, --utc, --universal    print or set Coordinated Universal Time (UTC)
      --help     display this help and exit
      --version  output version information and exit

 

     

                 2.内部命令:
                        help command 或man bash

                       

[root@contos7 ~]# help help
help: help [-dms] [pattern ...]
    Display information about builtin commands.
    
    Displays brief summaries of builtin commands.  If PATTERN is
    specified, gives detailed help on all commands matching PATTERN,
    otherwise the list of help topics is printed.
    
    Options:
      -d    output short description for each topic
      -m    display usage in pseudo-manpage format
      -s    output only a short usage synopsis for each topic matching
        PATTERN
    
    Arguments:
      PATTERN    Pattern specifiying a help topic
    
    Exit Status:
    Returns success unless PATTERN is not found or an invalid option is given.

 

 

三.man的使用

             man命令的实用性非常高,基本上所有的类Unix系统都支持,所以man的使用学习是非常重要的。我们之所以可以man到帮助文档,是因为系统里有帮助文档存在,提供man命令帮助的文件存在/usr/share/man目录下。
            1.  man的帮助文档分类

                  1. man1 Executable programs or shell commands 用户命令及应用程序
                  2. man2 System calls (functions provided by the kernel) 系统调用和内核出错代码
                  3. man3 Library calls (functions within program libraries) 库调用
                  4. man4 Special files (usually found in /dev) 设备驱动程序和网络协议
                  5. man5 File formats and conventions eg /etc/passwd 标准文件格式
                  6. man6 Games 游戏和演示
                  7. man7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) 各种文件和文档
                  8. man8 System administration commands (usually only for root) 系统管理命令
                  9. man9 Kernel routines [Non standard] 含糊的内核规范和接口

           2.man帮助段落说明

 

                     – NAME                           名称及简要说明

 

NAME
       man - an interface to the on-line reference manuals

                 

                  – SYNOPSIS                   用法格式说明

 

SYNOPSIS 
       man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-m
       system[,...]] [-M path] [-S list] [-e extension] [-i|-I] [--regex|--wildcard]
       [--names-only]  [-a]  [-u]  [--no-subpages]  [-P  pager] [-r prompt] [-7] [-E
       encoding]   [--no-hyphenation]   [--no-justification]   [-p   string]    [-t]
       [-T[device]] [-H[browser]] [-X[dpi]] [-Z] [[section] page ...] ...
       man -k [apropos options] regexp ...
       man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
       man -f [whatis options] page ...
       man  -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale]
       [-P pager] [-r prompt] [-7]  [-E  encoding]  [-p  string]  [-t]  [-T[device]]
       [-H[browser]] [-X[dpi]] [-Z] file ...
       man -w|-W [-C file] [-d] [-D] page ...
       man -c [-C file] [-d] [-D] page ...
       man [-?V]


                  – DESCRIPTION             详细说明

 

DESCRIPTION
       man is the system's manual pager. Each page argument given to man is normally
       the name of a program, utility or function.  The manual page associated  with
       each  of these arguments is then found and displayed. A section, if provided,
       will direct man to look only in that section  of  the  manual.   The  default
       action is to search in all of the available sections, following a pre-defined
       order and to show only the first page found, even if page exists  in  several
       sections.

       The table below shows the section numbers of the manual followed by the types
       of pages they contain.

 

 

                  – OPTIONS                     选项说明

 

OPTIONS
       Non  argument  options  that  are  duplicated  either on the command line, in
       $MANOPT, or both, are not harmful.  For options  that  require  an  argument,
       each duplication will override the previous argument value.

 

 

                  – EXAMPLES                  示例

 

man ls
           Display the manual page for the item (program) ls.

       man -a intro
           Display, in succession, all of the available intro manual pages contained
           within the manual.  It is possible to quit between successive displays or
           skip any of them.

 

 

                  – FILES                           相关文件

 

FILES
       /etc/man_db.conf
              man-db configuration file.

       /usr/share/man
              A global manual page hierarchy.

       /usr/share/man/index.(bt|db|dir|pag)
              A traditional global index database cache.

       /var/cache/man/index.(bt|db|dir|pag)
              An FHS compliant global index database cache.

       

          – SEE ALSO                    其它帮助参考

 

SEE ALSO
       apropos(1), groff(1), less(1),  manpath(1),  nroff(1),  troff(1),  whatis(1),
       zsoelim(1), setlocale(3), manpath(5), ascii(7), latin1(7), man(7), catman(8),
       mandb(8), the man-db package manual, FSSTND

 

 

 

         3.man的操作按键

                  空格键                              向下翻一页

                  Page Down                      向下翻一页

                  Page Up                           向上翻一页

                  y,k                                  向文件首部翻一行

                  e,j                                   向文件尾部翻一行

                  b                                       向文件首部翻屏

                  u                                       向文件首部翻半屏

                  d                                       向文件尾部翻半屏

                  HOME                              直接前往首页

                  END                                 直接前往尾页

                  1G                                    回到文件首部

                  G                                      翻至文件尾部

                  :                                     跳转至第#行

                  /关键词                             从上至下搜索某个关键词

                  ?关键词                          从下至上搜索某个关键词

                  n                                       定位到下一个搜索到的关键词

                  N                                      定位到上一个搜索到的关键词

                   q                                      推出帮助文档

 

四.info的使用

                man常用于命令参考,GNU工具info则更适合通用文档参考。info的页面的结构就像一个网站,没有参数,列出所有的页面,每一页分为“节点”,链接节点之前有”*”字符提示。 info帮助文档存放在/usr/share/info路径下。用法:info command

                

[root@contos7 ~]# info
File: dir       Node: Top       This is the top of the INFO tree

  This (the Directory node) gives a menu of major topics. 
  Typing "q" exits, "?" lists all Info commands, "d" returns here,
  "h" gives a primer for first-timers,
  "mEmacs<Return>" visits the Emacs topic, etc.

  In Emacs, you can click mouse button 2 on a menu item or cross reference
  to select it.

 

 

           info的操作按键

                       ?                              显示info的常用快捷键。

                      N                                显示(相对于本节点的)下一节点的文档内容

                      P                                显示(相对于本节点的)前一节点的文档内容

                      U                                进入当前命令所在的主题

                      M                                敲M键后输入命令的名称就可以查看该命令的帮助文档了

                      G                                敲G键后输入主题名称,进入该主题

                      L                                 回到上一个访问的页面

                      SPACE                       向前滚动一页

                      BACKUP或DEL          向后滚动一页

                      Q                                退出info

 

五.其他类型的获取帮助的方法

          1.本地帮助文档

              通过本地文档查看帮助,没有网络也可以获取这些资料,linux内部有很多的文档,这些文档无法用man 或info命令查看,只有进入到/usr/share/doc目录下才能查看,这里面的文件内容非常详尽。而且数量众多,只是/usr/share/doc/下就有1012条目录,这还不包括在这之下的子目录。
              /usr/share/doc目录下主要包含以下内容。
              - 多数安装了的软件包的子目录,包括了这些软件的相关原理说明
              - 常见文档:README INSTALL CHANGES
              - 不适合其它地方的文档的位置
              配置文件范例
              HTML/PDF/PS 格式的文档
              授权书详情

[root@contos7 ~]# ls /usr/share/doc/
abattis-cantarell-fonts-0.0.25         libsigc++20-2.10.0
abrt-2.1.11                            libSM-1.2.2
abrt-dbus-2.1.11                       libsndfile-1.0.25
accountsservice-0.6.45                 libsoup-2.56.0
acl-2.2.51                             libspectre-0.2.8
adcli                                  libsrtp-1.4.4
adcli-0.8.1                            libss-1.42.9
adwaita-qt5-1.0                        libssh2-1.4.3
aic94xx-firmware-30                    libstoragemgmt-1.6.1
alsa-firmware-1.0.28                   libsysfs-2.1.0
alsa-lib                               libtar-1.2.11
alsa-lib-1.1.4.1                       libtasn1-4.10
alsa-plugins-pulseaudio-1.1.1          libteam-1.27
alsa-tools-1.1.0                       libthai-0.1.14
alsa-utils-1.1.3                       libtheora-1.1.1
anaconda-core-21.48.22.134             libtiff-4.0.3
at-3.1.13                              libtimezonemap-0.4.4
atk-2.22.0                             libtirpc-0.2.4
atkmm-2.24.2                           libtool-ltdl-2.4.2

 

 

 

          2.在线文档帮助

 

              通过在线文档获取帮助,也是解决问题的常用方法。一般是去系统发行版或第三方软件发行商的官方网站去查找官方资料。顺便再介绍两个谷歌的搜索小技巧:
              1.Openstack file type:pdf 筛选指定类型的文件
              2.rhcasite:redhat.com /docs 在指定网站只搜索文档
              常见第三方应用程序官方文档
                 http://www.nginx.org
              http://tomcat.apache.org
              http://httpd.apache.org
              http://www.python.org

 

              通过发行版官方网站可以获得安装指南、部署指南、虚拟化指南等
              红帽知识库和官方在线文档链接:
              http://kbase.redhat.com
              http://www.redhat.com/docs
              http://access.redhat.com

 

             比较专业的网站和搜索:
             http://tldp.org
             http://www.slideshare.net
             http://www.google.com

          3.红帽知识库网站

              • rhn.redhat.com或者本地卫星服务器/代理服务器
              – 基于网络管理的服务器
              – RHN代理服务器为RHN流量提供缓存
              – RHN卫星服务器提供自主的RHN
              • RHN账户
              – 为及其注册和基于网络管理的RHN用户
              – 用于系统自动验证的系统ID
              • sosreport
              收集所有系统上的日志信息的工具,并自动打成压缩包,方便技术支持
              人员和红帽全球支持提供分析问题依据

 

posted on 2018-07-17 17:12  青山揽流萤  阅读(935)  评论(1编辑  收藏  举报

导航