【shell学习|003】- 查找文档

查找文档

接上一节【shell学习|002】- 认识命令行终端

Linux 发行版通常不附带纸质的参考手册或者光盘。然而,它的在线文档一直是 Linux 的优势之一。
从操作系统的早期版本开始,就可以通过 man 和 info 实用程序访问 man(或手册)和 info 页面。
本节讨论了一些您可以在 Linux 上查找帮助信息的地方。

part1、获取帮助的基本方法

1、man命令:查看系统的man手册

下图是man man的结果:在这里插入图片描述
具体可以参考这篇文章:man手册

2、apropos:搜索关键字

man apropos:

APROPOS(1)                                        Manual pager utils                                       APROPOS(1)

NAME
       apropos - search the manual page names and descriptions

SYNOPSIS
       apropos [-dalv?V] [-e|-w|-r] [-s list] [-m system[,...]] [-M path] [-L locale] [-C file] keyword ...

DESCRIPTION
       Each manual page has a short description available within it.  apropos searches the descriptions for instances
       of keyword.

       keyword is usually a regular expression, as if (-r) was used, or may contain  wildcards  (-w),  or  match  the
       exact  keyword  (-e).  Using these options, it may be necessary to quote the keyword or escape (\) the special
       characters to stop the shell from interpreting them.

       The standard matching rules allow matches to be made against the page name and word boundaries in the descrip?
       tion.

       The database searched by apropos is updated by the mandb program.  Depending on your installation, this may be
       run by a periodic cron job, or may need to be run manually after new manual pages have been installed.

OPTIONS
       -d, --debug
              Print debugging information.

       -v, --verbose

当您不知道执行特定任务所需的命令名称时,您可以使用带有关键字的 apropos 进行搜索。
此实用程序在所有手册页的简短描述行中搜索关键字,并显示包含匹配项的关键字。
man -k,提供与 apropos 相同的输出。

[shiqiu@theThree ~]$ apropos  whoami
npm-whoami (1)       - Display npm username
whoami (1)           - print effective userid
[shiqiu@theThree ~]$ 

从man结果我们可以看到:aprops使用的数据库的更新是mandb命令,
需要注意的是如果系统版本是centos6或以下的版本的话更新的命令是makewhatis

3、whatis

whatis的结果和apropos类似,不过只能找到与实用程序名匹配的完整单词,可以看做是简化版的apropos;这么说可能比较抽象,下面对比两个命令结果看下:

(base) [root@theThree ~]# apropos who
Test2::Tools::Tiny (3pm) - Tiny set of tools for unfortunate souls who cannot use Test2::Suite.
at.allow (5)         - determine who can submit jobs via at or batch
at.deny (5)          - determine who can submit jobs via at or batch
btrfs-filesystem (8) - command group of btrfs that usually work on the whole filesystem
docker-trust-signer (1) - Manage entities who can sign Docker images
ipsec_newhostkey (8) - generate a new raw RSA authentication key for a host
ipsec_showhostkey (8) - show host's authentication key
npm-whoami (1)       - Display npm username
w (1)                - Show who is logged on and what they are doing.
who (1)              - show who is logged on
who (1p)             - display who is on the system
whoami (1)           - print effective userid
(base) [root@theThree ~]# 
(base) [root@theThree ~]# 
(base) [root@theThree ~]# whatis who
who (1)              - show who is logged on
who (1p)             - display who is on the system
(base) [root@theThree ~]# 

4、info:显示有关实用程序的信息

man info:

INFO(1)                                             User Commands                                             INFO(1)

NAME
       info - read Info documents

SYNOPSIS
       info [OPTION]... [MENU-ITEM...]

DESCRIPTION
       Read documentation in Info format.

OPTIONS
       -k, --apropos=STRING
              look up STRING in all indices of all manuals.

       -d, --directory=DIR
              add DIR to INFOPATH.

       --dribble=FILENAME
              remember user keystrokes in FILENAME.

       -f, --file=FILENAME
              specify Info file to visit.

       -h, --help
              display this help and exit.

       --index-search=STRING
              go to node pointed by index entry STRING.

info info:

File: info.info,  Node: Top,  Next: Getting Started,  Up: (dir)

Info: An Introduction
*********************

The GNU Project distributes most of its on-line manuals in the "Info
format", which you read using an "Info reader".  You are probably using
an Info reader to read this now.

   There are two primary Info readers: 'info', a stand-alone program
designed just to read Info files (*note What is Info?: (info-stnd)Top.),
and the 'info' package in GNU Emacs, a general-purpose editor.  At
present, only the Emacs reader supports using a mouse.

   If you are new to the Info reader and want to learn how to use it,
type the command 'h' now.  It brings you to a programmed instruction
sequence.

   To read about advanced Info commands, type 'n' twice.  This brings
you to 'Advanced Info Commands', skipping over the 'Getting Started'
chapter.

   This file describes how to use Info, the on-line, menu-driven GNU
documentation system.

   Copyright (C) 1989, 1992, 1996-2012 Free Software Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this
man 和info的不同:
info 实用程序比 man 显示关于 GNU 实用程序的更完整和最新的信息。
当手册页显示有关 info 涵盖的实用程序的缩写信息时,手册页指的是 info。 
man 实用程序经常显示有关非 GNU 实用程序的唯一可用信息。
当 info 显示有关非 GNU 实用程序的信息时,它通常是手册页的副本。

5、命令的 - -help 参数

大多数 GNU 实用程序都提供了一个 ––help 选项,用于显示有关实用程序的信息。
非 GNU 实用程序可能会使用 –h 或 –help 选项来显示有关其自身的信息。

(base) [root@theThree ~]# man --help
Usage: man [OPTION...] [SECTION] PAGE...

  -C, --config-file=FILE     use this user configuration file
  -d, --debug                emit debugging messages
  -D, --default              reset all options to their default values
      --warnings[=WARNINGS]  enable warnings from groff

 Main modes of operation:
  -f, --whatis               equivalent to whatis
  -k, --apropos              equivalent to apropos
  -K, --global-apropos       search for text in all pages
  -l, --local-file           interpret PAGE argument(s) as local filename(s)
  -w, --where, --path, --location
                             print physical location of man page(s)
  -W, --where-cat, --location-cat
                             print physical location of cat file(s)

  -c, --catman               used by catman to reformat out of date cat pages
  -R, --recode=ENCODING      output source page encoded in ENCODING

 Finding manual pages:
  -L, --locale=LOCALE        define the locale for this particular man search
  -m, --systems=SYSTEM       use manual pages from other systems
  -M, --manpath=PATH         set search path for manual pages to PATH

  -S, -s, --sections=LIST    use colon separated section list

  -e, --extension=EXTENSION  limit search to extension type EXTENSION

  -i, --ignore-case          look for pages case-insensitively (default)
  -I, --match-case           look for pages case-sensitively

      --regex                show all pages matching regex
      --wildcard             show all pages matching wildcard

      --names-only           make --regex and --wildcard match page names only,
                             not descriptions

  -a, --all                  find all matching manual pages
  -u, --update               force a cache consistency check

      --no-subpages          don't try subpages, e.g. 'man foo bar' => 'man
                             foo-bar'

 Controlling formatted output:
  -P, --pager=PAGER          use program PAGER to display output
  -r, --prompt=STRING        provide the `less' pager with a prompt

  -7, --ascii                display ASCII translation of certain latin1 chars
  -E, --encoding=ENCODING    use selected output encoding
      --no-hyphenation, --nh turn off hyphenation
      --no-justification,                              --nj   turn off justification
  -p, --preprocessor=STRING  STRING indicates which preprocessors to run:
                             e - [n]eqn, p - pic, t - tbl,
g - grap, r - refer, v - vgrind

  -t, --troff                use groff to format pages
  -T, --troff-device[=DEVICE]   use groff with selected device

  -H, --html[=BROWSER]       use elinks or BROWSER to display HTML output
  -X, --gxditview[=RESOLUTION]   use groff and display through gxditview
                             (X11):
                             -X = -TX75, -X100 = -TX100, -X100-12 = -TX100-12
  -Z, --ditroff              use groff and force it to produce ditroff

  -?, --help                 give this help list
      --usage                give a short usage message
  -V, --version              print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Report bugs to cjwatson@debian.org.

6、bash中的help命令

bash help 命令显示有关 bash 命令、控制结构和其他功能的信息。
在 bash 提示符下,提供命令帮助,后跟您感兴趣的关键字。 以下是一些示例:

(base) [root@theThree ~]# 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.
(base) [root@theThree ~]# help echo 
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs on the standard output followed by a newline.
    
    Options:
      -n	do not append a newline
      -e	enable interpretation of the following backslash escapes
      -E	explicitly suppress interpretation of backslash escapes
    
    `echo' interprets the following backslash-escaped characters:
      \a	alert (bell)
      \b	backspace
      \c	suppress further output
      \e	escape character
      \f	form feed
      \n	new line
      \r	carriage return
      \t	horizontal tab
      \v	vertical tab
      \\	backslash
      \0nnn	the character whose ASCII code is NNN (octal).  NNN can be
    	0 to 3 octal digits
      \xHH	the eight-bit character whose value is HH (hexadecimal).  HH
    	can be one or two hex digits
    
    Exit Status:
    Returns success unless a write error occurs.

part2、获取帮助的其他途径(授人以渔)

7、获取本地帮助文档

linux本地帮助文档的路径在/usr/share/doc/中:

(base) [root@theThree ~]# ls /usr/share/doc/ |more 
abattis-cantarell-fonts-0.0.25
abrt-2.1.11
abrt-dbus-2.1.11
accountsservice-0.6.45
acl-2.2.51
adcli
adcli-0.8.1
aic94xx-firmware-30
alsa-firmware-1.0.28
alsa-lib
alsa-lib-1.1.3
alsa-lib-devel-1.1.3
alsa-plugins-pulseaudio-1.1.1
alsa-tools-1.1.0
...

查看一下其中acl相关手册的信息:

(base) [root@theThree ~]# ll /usr/share/doc/acl-2.2.51
total 68
-rw-r--r--. 1 root root  8296 Jun 10  2014 CHANGES.gz
-rw-r--r--. 1 root root 18311 Jun 10  2014 COPYING
-rw-r--r--. 1 root root 26762 Jun 10  2014 COPYING.LGPL
-rw-r--r--. 1 root root  3208 Jun 10  2014 PORTING
-rw-r--r--. 1 root root   410 Jun 10  2014 README
(base) [root@theThree ~]# cat /usr/share/doc/acl-2.2.51/README 
Access control list package README
__________________________________

Package home: http://savannah.nongnu.org/projects/acl

See the file doc/INSTALL for build, installation and post-
install configuration steps.

Refer to the acl(5) manual page for general access control list
information and references to other related manual pages.

For more information on the build process, please refer to
doc/PORTING.
(base) [root@theThree ~]# 

8、网络资源:

在7中我们可以从acl的README文档中看到acl的首页,我们打开浏览器访问看下:
在这里插入图片描述
这个页面上应该有acl相关的最权威的信息了;
其他命令的相关文档都可以通过这个方式查看

9、一些推荐的手册及学习站点:

  1. Debian 说明文档
  2. Redhat官方手册页
  3. linux kernel
  4. 鸟哥私房菜在线地址
  5. libgen搜书地址
  6. digitalocean,很好的教程地址

下一篇

【shell学习|004】

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值