Linux-man & info

man page & info page


man page 的使用

man是manual(操作说明)的简写。

macdeMacBook-Air:~ mac$ man
What manual page do you want?

以date命令为例

DATE(1)                   BSD General Commands Manual                  DATE(1)

NAME
     date -- display or set date and time

SYNOPSIS
     date [-jRu] [-r seconds | filename] [-v [+|-]val[ymwdHMS]] ...
          [+output_fmt]
     date [-jnu] [[[mm]dd]HH]MM[[cc]yy][.ss]
     date [-jnRu] -f input_fmt new_date [+output_fmt]
     date [-d dst] [-t minutes_west]

DESCRIPTION
     When invoked without arguments, the date utility displays the current
     date and time.  Otherwise, depending on the options specified, date will
     set the date and time or print it in a user-defined way.

     The date utility displays the date and time read from the kernel clock.
     When used to set the date and time, both the kernel clock and the hard-
     ware clock are updated.
    ---中间省略---
    ENVIRONMENT
     The following environment variables affect the execution of date:

     TZ      The timezone to use when displaying dates.  The normal format is
             a pathname relative to /usr/share/zoneinfo.  For example, the
             command ``TZ=America/Los_Angeles date'' displays the current time
             in California.  See environ(7) for more information.

FILES
     /var/log/messages  record of the user setting the time

EXIT STATUS
     The date utility exits 0 on success, 1 if unable to set the date, and 2
     if able to set the local date, but unable to set it globally.

EXAMPLES
     The command:
---中间省略---
DIAGNOSTICS
     Occasionally, when timed(8) synchronizes the time on many hosts, the set-
     ting of a new time value may require more than a few seconds.  On these
     occasions, date prints: `Network time being set'.  The message
     `Communication error with timed' occurs when the communication between
     date and timed(8) fails.

LEGACY SYNOPSIS
     As above, except for the second line, which is:

     date [-jnu] [[[[[cc]yy]mm]dd]HH]MM[.ss]

LEGACY DIAGNOSTICS
     When invoked in legacy mode, the following exit values are returned:
     0  The date was written successfully
     1  Unable to set the date
     2  Able to set the local date, but unable to set it globally

     For more information about legacy mode, see compat(5).

SEE ALSO
     locale(1), gettimeofday(2), getutxent(3), strftime(3), strptime(3),timed(8)

     R. Gusella and S. Zatti, TSP: The Time Synchronization Protocol for UNIX
     4.3BSD.

STANDARDS
     The date utility is expected to be compatible with IEEE Std 1003.2
     (``POSIX.2'').  The -d, -f, -j, -n, -r, -t, and -v options are all exten-
     sions to the standard.

HISTORY
     A date command appeared in Version 1 AT&T UNIX.

BSD                               May 7, 2015                              BSD
(END)

进入man命令的功能后,你可以按下空格键往下翻页,可以按下“q”按键来离开man的环境。


  1. 注意-man date命令 首先出现的DETE(1) 中(1)的意思

    (1)代表的是一般用户可使用的命令。在查询数据的后面的数字是有意义的。它可以帮助我们了解或者是直接查询相关的资料。常见的几个数字的意义如下表。

    代号 代表内容
    1 用户在shell环境中可以操作的命令或可执行文件
    2 系统内核课调用的函数与工具等
    3 一些常用的函数(function)与函数库(library),大部分为C的函数库(libc)
    4 设备文件的说明,通常在/dev 下的文件
    5 配置文件或者是某些文件的格式
    6 游戏(games)
    7 惯例与协议等,例如Linux文件系统、网络协议、ASCll code等说明
    8 系统管理员可用的管理命令
    9 跟kernel有关的文件

2.man page内容主要划分为下面这几个主要部分

man page的内容也分成好几个部分来加以介绍。前面的man page中,以NAME作为开始介绍,最后有个 SEE ALSO来作为结束。基本上,man page大致分为下面几个部分。

代号 内容说明
NAME 简短的命令、数据名称说明
SYNOPSIS 简短的命令执行语法(syntax)简介
DESCRIPTION 较为完整的说明,这部分需要仔细看看
OPTIONS 针对SYNOPSIS部分中,有列举的所有可用的选项说明
COMMANDS 当这个程序(软件)在执行的时候,可以在此程序(软件)中执行的命令
FILES 这个程序或数据所使用或参考或连接到的某些文件
SEE ALSO 这个命令或数据有关的其他说明
EXAMPLE 一些可以参考的范例
BUGS 是否有相关的错误

3.在man page 中常用的按键

按键 进行工作
空格键 向下翻一页
[Page Down]—— 向下翻一页
[Page Up] 向上翻一页
[Home] 去到第一页
[End] 去到最后一页
/string 向下查询string字符串,如果要查询cpyh的话,就输入/cpyh
?string 向上查询string字符串
n,N 利用/或?来查询字符串时,可以使用n来继续下一个查询(不论是/或?),可以利用N来进行反向查询。
q 结束这次的man page

上面的按键必须在man page的界面当中才能使用。

4.查询特定命令/文件的man page说明文件

在某些情况下,我们可能知道要使用某些特定的命令或者是修改某些特定的配置文件,但是忘记来该命令的完整名称。有些时候则是只记得该命令的部分关键字。这个时候如何查找出来想要知道的man page呢?

-f参数:用于查找系统中所有跟(命令)有关的说明文件(以man为例)

macdeMacBook-Air:~ mac$ man -f man
IO::Socket::SSL::Intercept(3pm) - -- SSL interception (man in the middle)
Pod::Man(3pm)            - Convert POD data to formatted *roff input
Pod::Perldoc::ToMan(3pm) - let Perldoc render Pod as man pages
groff_man(7)             - groff `man' macros to support generation of man pages
groffer(1)               - display groff files and man~pages on X and tty
man(1)                   - format and display the on-line manual pages
man.conf(5)              - configuration data for man
zshall(1)                - the Z shell meta-man page

-k参数:在系统的说明文件中,只要有(命令)这个关键字就将该说明列出来

APR::Brigade(3pm)        - Perl API for manipulating APR Bucket Brigades
APR::Bucket(3pm)         - Perl API for manipulating APR Buckets
APR::Date(3pm)           - Perl API for APR date manipulating functions
APR::String(3pm)         - Perl API for manipulating APR UUIDs
APR::Table(3pm)          - Perl API for manipulating APR opaque 
git-reflog(1)            - Manage reflog information
git-remote(1)            - Manage set of tracked repositories
git-remote-ext(1)        - Bridge smart transport to external command
git-worktree(1)          - Manage multiple working trees
---省略---

5.其他与man page相关

whatis[命令或者是数据]<==相当于man -f [命令或者是数据]
apropos[命令或者是数据]<==相当于man -k [命令或者是数据]
注意:这两个特殊命令使用的前提是创建 whatis 数据库才行。这个数据库的创建需要以root的身份执行如下命令

sh-3.2# makewhatis


info page的使用

与man page的主要区别
man page一下子输出一堆信息,info page则是将文件数据拆分成一个一个的段落,每个段落用自己的页面来撰写,并且在各个页面中还有类似网页的“超链接”来跳到各不同的页面中,每个独立的页面也被称为一个节点(node)。

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, 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 expert-level Info commands, type `n' twice.  This
brings you to `Info for Experts', skipping over the `Getting Started'
chapter.

-----Info:(info.info)Top,29 行 --Top---------------------------------------
欢迎使用 Info 4.8 版。输入 ? 以获得帮助,m 将得到菜单。

·File:代表这个info page的数据是来自info.info文件提供的。

·Node:代表目前的这个页面是属于Top节点。意思是info.info内含有很多信息,而Top仅是info.info文件内的一个节点内容而已。

·Next:下一个节点的名称为Getting Started,你也可以按“N”到下个节点去。

·Up:回到上一层的节点总揽界面,也可以按下“U”回到上一层。

·Prev:前一个节点。这里已经是第一个节点,所以没有上一个节点。

info的说明文件将内容分成多个节点,并且每个节点都有定位与链接。在各链接之间还可以具有类似“超链接”的快速按钮,可以通过[Tab]键在各个超链接间移动,也可以使用U、P、N键来在各个阶层与相关链接中显示。
附info page当中可以使用的按键及功用。

按键 进行工作
空格键 向下翻一页
[Page Down] 向下翻一页
[Page Up] 向上翻一页
[Tab] 在节点之间移动,有节点的地方,通常会以“*”显示
[Enter] 当光标在节点上面时,按下[Enter]可以进入该节点
B 移动光标到该info界面当中的第一个节点处
E 移动光标到该info界面当中的最后一个节点处
N 前往下一个节点处
P 前往上一个节点处
U 向上移动一层
S(/) 在info page当中进行查询
H 显示求助菜单
命令一览表
Q 结束这次的info page

info page必须用info page的格式来写成在线求助文件。如果一个命令不是以info page格式写成的说明文件,那么使用info命令与man命令得到的结果相同。


其他有用的文件(documents)?

在线帮助文件只是很少的一部分,还有相当多的说明需要额外的文件。这些文件以TXT、HTML、PDF等格式保存在/usr/share/doc目录中。


快捷使用
几乎所有命令都可以使用-h或–help参数获取使用方法,参数信息等。


*本文参阅图书:鸟哥的Linux私房菜(基础学习篇(第三版))*
       *示例为在mac air上的终端显示结果*

猜你喜欢

转载自blog.csdn.net/stupid_dernier/article/details/80152449