用途说明

man命令是个常用的命令,如果你稍微熟悉Unix/Linux系统的话,它用来显示在线手册页,是获取命令、函数、配置文件等的帮助信息的重要手段,另外一个手段是info命令。manpage就是手册页,它有一定的编写格式,Linux系统在文档方面是做得相当不错的,这给我们使用Linux提 供了方便。shell内置命令的手册页,显示的是bash全部内置命令的手册页,可以采用help命令来获取内置命令的帮助信息。

常用参数

格式:man <cmd>

显示<cmd>命令的手册页。默认情况下,man命令使用less作为显示文档的命令。

手册页的操作指令:

按q退出,这个最重要,因为Ctrl+C都没法退出来

按下箭头可以往后一行

按回车或者上箭头可以往前一行

按End键可以翻到最后一页

按Home键可以翻到第一页

按空白键或者PgDn键可以往后翻一页

按PgUp键可以往前翻一页

输入/keyword回车可以搜索keyword

输入?keyword回车可以往前搜索keyword

按n可以往前或往后搜索下一个

格式:man -k<cmd>

格式:apropos<cmd>

显示与<cmd>有关的手册页列表。

格式:man 1 <cmd>

显示<cmd>命令的手册页。

格式:man 2<syscall>

显示系统调用<syscall>的手册页。

格式:man<section> <name>

显示<name>指定章节<section>的手册页,其中<section>包括

1、Standard commands(标准命令)

2、System calls(系统调用)

3、Library functions(库函数)

4、Special devices(设备说明)

5、File formats(文件格式)

6、Games and toys(游戏和娱乐)

7、Miscellaneous (杂项)

8、AdministrativeCommands (管理员命令)

使用示例

示例一 显示man的手册页

[root@jfht ~]# man man

man(1)                                                                 man(1)

NAME

man - format and display the on-line manual pages

SYNOPSIS

man  [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-Mpathlist] [-P pager] [-B browser] [-H

htmlpager] [-S section_list] [section] name ...

DESCRIPTION

man formats and displays the on-line manual pages.  If you specifysection, man only looks in that  section  of

the  manual.  name is normally the name of the manual page, which istypically the name of a command, function,

or file.  However, if name contains a slash (/) then man interprets it asa file specification, so that you can

do man ./foo.5 or even man /cd/foo/bar.1.gz.

See below for a description of where man looks for the manual page files.

OPTIONS

-C  config_file

Specify the configuration file to use; the default is /etc/man.config. (See man.config(5).)

-M  path

Specify  the  list  of  directories  to search for manpages.  Separate the directories with colons.  An

empty list is the same as not specifying -M at all.  See SEARCH PATH FORMANUAL PAGES.

-P  pager

Specify which pager to use.  This option overrides the MANPAGER environment  variable,  which  in  turn

overrides the PAGER variable.  By default, man uses /usr/bin/less -is.

-B     Specify  which browser to use on HTMLfiles.  This option overrides the BROWSER environment variable. By

default, man uses /usr/bin/less-is,

-H     Specify a command that renders HTML files astext.  This  option  overrides  the  HTMLPAGER environment

variable. By default, man uses /bin/cat,

-S  section_list

List is a colon separated list of manual sections to search.  This optionoverrides the MANSECT environ-

ment variable.

-a     By default, man will exit after displaying the firstmanual page it finds.  Using this option forces man

:q

[root@jfht ~]#

示例二 显示C函数printf的手册页

[root@jfht ~]# man printf

PRINTF(1)                       UserCommands                      PRINTF(1)

NAME

printf - format and print data

SYNOPSIS

printf FORMAT [ARGUMENT]...

printf OPTION

DESCRIPTION

Print ARGUMENT(s) according to FORMAT.

--help display this help and exit

--version

output version information and exit

FORMAT controls the output as in C printf.  Interpreted sequences are:

\"     double quote

\NNN   character with octal value NNN (1 to 3 digits)

\\     backslash

\a     alert (BEL)

\b     backspace

\c     produce no further output

\f     form feed

\n     new line

\r     carriage return

\t     horizontal tab

\v     vertical tab

:q

注:上面显示的是命令printf的手册页,但不是C函数printf的手册页。

[root@jfht ~]# man 3 printf

PRINTF(3)                 Linux Programmer’sManual                PRINTF(3)

NAME

printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf -formatted output conversion

SYNOPSIS

#include <stdio.h>

int printf(const char *format, ...);

int fprintf(FILE *stream, const char *format, ...);

int sprintf(char *str, const char *format, ...);

int snprintf(char *str, size_t size, const char *format, ...);

#include <stdarg.h>

int vprintf(const char *format, va_list ap);

int vfprintf(FILE *stream, const char *format, va_list ap);

int vsprintf(char *str, const char *format, va_list ap);

int vsnprintf(char *str, size_t size, const char *format, va_list ap);

DESCRIPTION

The  functions  in  the  printf() family produce outputaccording to a format as described below. The functions

printf() and vprintf() write output to stdout, the standard output stream;fprintf() and vfprintf() write  out-

put to the given output stream; sprintf(), snprintf(), vsprintf() andvsnprintf() write to the character string

str.

The functions vprintf(),  vfprintf(),  vsprintf(), vsnprintf()  are  equivalent  to  the  functions printf(),

fprintf(),  sprintf(),  snprintf(), respectively, except that theyare called with a va_list instead of a vari-

able number of arguments. These functions do not call the va_end macro.Consequently, the value of ap is  unde-

fined after the call. The application should call va_end(ap) itself afterwards.

These eight functions write the output under the control of a format stringthat specifies how subsequent argu-

ments (or arguments accessed via the variable-length argument facilities ofstdarg(3)) are converted  for  out-

put.

Returnvalue

Upon  successful  return,  these  functions return thenumber of characters printed (not including the trailing

’\0’ used to end output to strings).  The functions snprintf() andvsnprintf() do  not  write  more  than  size

bytes  (including  the  trailing ’\0’).  If the output wastruncated due to this limit then the return value is

the number of characters (not including the trailing ’\0’) which would havebeen written to the final string if

[root@jfht ~]#

示例三 查找与kill有关的手册页

[root@jfht ~]# man-k kill

kill                (1)  - terminate a process

kill                (1p)  - terminate or signal processes

kill                (2)  - send signal to a process

kill                (3p)  - send a signal to a process or a group of processes

kill[builtins]      (1)  - bash built-in commands,see bash(1)

killall             (1)  - kill processes by name

killchar[curs_termattrs] (3x)  - curses environment query routines

killpg              (2)  - send signal to a process group

killpg              (3)  - send signal to all members of a process group

killpg              (3p)  - send a signal to a process group

killwchar[curs_termattrs] (3x)  - curses environment query routines

mysql_waitpid       (1)  - kill process and wait for its termination

mysql_zap           (1)  - kill processes that match a pattern

pkill[pgrep]        (1)  - look up or signalprocesses based on name and other attributes

pthread_kill        (3p)  - send a signal to a thread

skill               (1)  - send a signal or report process status

snice[skill]        (1)  - send a signal orreport process status

tgkill              (2)  - Send signal sig to one specific thread, tgid

tkill               (2)  - send a signal to a single process

xkill               (1x)  - kill a client by its X resource

yes                 (1)  - output a string repeatedly until killed

[root@jfht ~]#

源文档 <http://codingstandards.iteye.com/blog/971078>

man page

嗄?不知道怎么使用date 这个指令?嘿嘿嘿!不要担心,我们 Linux 上面的在线求助系统已经都帮您想好要怎么办了,所以你只要使用简单的方法去寻找一下说明的内容, 马上就清清楚楚的知道该指令的用法了!怎么看呢?就是找男人( man ) 呀!?喔!不是啦!这个 man 是 manual (操作说明) 的简写啦!只要下达: 『man date』 马上就会有清楚的说明出现在你面前喔!如下所示:

[root@linux ~]#LANG="en"
# 还记得这个咚咚的用意吧?前面提过了,是为了『语系』的需要啊!下达过一次即可!
[root@linux ~]# man date
DATE(1)                          UserCommands                         DATE(1)

NAME
       date - print or set the systemdate and time

SYNOPSIS
       date [OPTION]...[+FORMAT]
       date [-u|--utc|--universal][MMDDhhmm[[CC]YY][.ss]]

DESCRIPTION
       Display the current time in thegiven FORMAT, or set the system date.

-d,--date=STRING
              display time described bySTRING, not 'now'

-f,--file=DATEFILE
              like --date once for eachline of DATEFILE

-ITIMESPEC,--iso-8601[=TIMESPEC]
              output  date/time in ISO 8601 format.  TIMESPEC='date'for date
              only, 'hours', 'minutes',or 'seconds' for date and time to the
              indicated  precision.  --iso-8601  without TIMESPECdefaults to
              'date'.
................(略)....
AUTHOR
       Written by David MacKenzie.

REPORTINGBUGS
       Report bugs to .

COPYRIGHT
       Copyright ?2004 Free SoftwareFoundation, Inc.
       This is free software; see thesource for copying conditions.  Thereis
       NO warranty; not even forMERCHANTABILITY or FITNESS FOR  A  PARTICULAR
       PURPOSE.

SEE ALSO
       The  full documentation for date is maintained asa Texinfo manual.  If
       the info and date programs areproperly installed  at  your site,  the
       command

info coreutils date

should give youaccess to the complete manual.

date (coreutils)5.2.1             May 2005                            DATE(1)

看!马上就知道一大堆的用法了!如此一来,不就可以知道date 的相关参数了吗?呵呵!真方便! 而出现的这个屏幕画面,我们称呼他为 man page , 您可以在里头查询他的用法与相关的参数说明。如果仔细一点来看这个 man page 的话, 您会发现几个有趣的东西。

首先,在上个表格的第一行,您可以看到的是:『DATE(1)』,DATE 我们知道是指令的名称, 那么 (1) 代表什么呢?他代表的是『一般用户可使用的指令』的意思!咦!还有这个用意啊!!呵呵! 没错~在查询数据的后面的数字是有意义的喔!他可以帮助我们了解或者是直接查询相关的资料。 常见的几个数字的意义是这样的:

代号

代表内容

1

用户可以操作的指令或可执行文件

2

系统核心可呼叫的函数与工具等

3

一些常用的函数(function)与函式库(library)

4

装置档案的说明

5

配置文件或者是某些档案的格式

6

游戏(games)

7

惯例与协议等,例如 Linux 标准文件系统、 网络协议、ASCII code 等等的说明内容

8

系统管理员可用的管理指令

9

跟 kernel 有关的文件

所以,未来您如果使用man page 在察看某些数据时,就会知道该指令/档案所代表的基本意义是什么了。 举例来说,如果您下达了 man null 时,会出现的第一行是:『NULL(4)』,对照一下上面的数字意义, 嘿嘿!原来 null 这个玩意儿竟然是一个『装置档案』呢!很容易了解了吧!?

再来,manpage 的内容也分成好几个部分来加以介绍该指令呢!就是上头 man date 那个表格内, 以 NAME 作为开始介绍,最后还有个SEE ALSO 来作为结束。基本上, man page 大致分成底下这几个部分:

代号

内容说明

NAME

简短的指令、数据名称说明

SYNOPSIS

简短的指令下达语法(syntax)简介

DESCRIPTION

较为完整的说明,这部分最好仔细看看!

OPTIONS

针对 SYNOPSIS 部分中,有列举的所有可用的参数说明

COMMANDS

当这个程序(软件)在执行的时候,可以在此程序(软件)中下达的指令

FILES

这个程序或数据所使用或参考或连结到的某些档案

SEE ALSO

可以参考的,跟这个指令或数据有相关的其他说明!

EXAMPLE

一些可以参考的范例

BUGS

是否有相关的臭虫!

有时候除了这些外,还可能会看到Authors 与 Copyright 等等,不过也有很多时候仅有 NAME 与 DESCRIPTION 等部分。 通常鸟哥在查询某个数据时,一定会察看NAME 约略看一下这个数据的意思,再详看一下 DESCRIPTION ,这个 DESCRIPTION 会提到很多相关的资料与使用时机,从这个地方可以学到很多小细节呢!而如果这个指令其实很熟悉了 (例如上面的 date ),那么鸟哥主要就是查询关于 OPTIONS 的部分了!可以知道每个参数的意思, 这样就可以下达比较细部的指令内容呢!最后,鸟哥会再看一下,啊跟这个资料有关的还有哪些东西可以使用的? 举例来说,上面的 SEE ALSO 就告知我们还可以利用『info coreutils date』来进一步查阅数据, 某些说明内容还会列举有关的档案(FILES 部分) 来提供我们参考!这些都是很有帮助的!

好了,大致上了解了man page 的内容后,那么,在 man page 当中我还可以利用哪些按键来帮忙查阅呢? 首先,如果要向下翻页的话,可以按下键盘的 空格键 ,也可以使用 [PageUp] 与[Page Down] 来翻页呢!同时,如果您知道某些关键词的话, 那么可以在任何时候输入『 /word 』,来主动搜寻关键词!例如在上面的搜寻当中, 我输入了 /date 会变成怎样?

DATE(1)                          User Commands                         DATE(1)

NAME
       date - print or set the systemdate and time

SYNOPSIS
       date [OPTION]...[+FORMAT]
       date [-u|--utc|--universal][MMDDhhmm[[CC]YY][.ss]]

DESCRIPTION
       Display the current time in thegiven FORMAT, or set the system date.

...........(中间省略)........

/date

看到了吗?您按下『/』之后,光标应该就会移动到屏幕的最下面一行,并等待您输入搜寻的字符串了。此时,输入 date 后, man page 就会开始搜寻跟 date 有关的字符串, 并且移动到该区域呢!很方便吧!最后,如果要离开 man page 时,直接按下『 q 』就能够离开了。 我们将一些在 man page 常用的按键给他整理整理:

按键

进行工作

空格键

向下翻一页

[Page Down]

向下翻一页

[Page Up]

向上翻一页

[Home]

去到第一页

[End]

去到最后一页

/string

向『下』搜寻 string 这个字符串,如果要搜寻 vbird 的话,就输入 /vbird

?string

向『上』搜寻 string 这个字符串

n, N

利用 / 或 ? 来搜寻字符串时,可以用 n 来继续下一个搜寻 (不论是 / 或 ?) ,可以利用 N 来进行『反向』搜寻。举例来说,我以 /vbird 搜寻 vbird 字符串, 那么可以 n 继续往下查询,用 N 往上查询。若以 ?vbird 向上查询 vbird 字符串, 那我可以用 n 继续『向上』查询,用 N 反向查询。

q

结束这次的 man page

要注意喔!上面的按键是在man page 的画面当中才能使用的! 比较有趣的是那个搜寻啦!我们可以往下或者是往上搜寻某个字符串,例如要在 man page 内搜寻 vbird 这个字符串, 可以输入 /vbird 或者是 ?vbird ,只不过一个是往下而一个是往上来搜寻的。而要 重复搜寻 某个字符串时,可以使用 n 或者是 N 来动作即可呢! 很方便吧!^_^

既然有man page ,自然就是因为有一些文件数据,所以才能够以 man page 来读出来啰! 那么这些 man page的数据 放在哪里呢?不同的distribution 通常可能有点差异性,不过,通常是放在 /usr/share/man 这个目录里头,然而,我们可以透过修改他的 man page 搜寻路径来改善这个目录的问题!修改/etc/man.config ( 有的版本为 man.conf 或 manpath.conf) 即可啰!至于更多的关于 man 的讯息您可以使用『 manman 』来查询呦!关于更详细的设定,我们会在 Shell 的章节当中继续的说明喔!

man还有一些有趣的使用方式呢!举例来说,如果您还想要知道更多跟 man 有较相关的讯息, 可以下达:

[root@linux ~]# man-f man
man                  (1)  - format and display the on-line manualpages
man                  (7)  - macros to format man pages
man.conf [man]       (5)  - configuration data for man

看到了吗?使用-f 的参数,可以取得更多的 man 的相关信息,而上头这个表格当中,也有提示了 (数字) 的内容, 举例来说,第二行的『 man(7) 』表示有个 man (7) 的说明文件存在喔!但是却有个 man (1) 存在啊! 那当我们下达『 man man 』的时候,到底是找到哪一个说明档呢?嘿嘿!混乱了吧?! 其实,您可以指定不同的文件的,举例来说,上表当中的两个 man 您可以这样将他的文件叫出来:

[root@linux~]# man 1 man  <==这里是用 man(1) 的文件数据
[root@linux ~]# man 7 man  <==这里是用 man(7) 的文件数据

你可以自行将上面两个指令输入一次看看,就知道,两个指令输出的结果是不同的。那个1, 7 就是分别取出在 man page 里面关于 1 与 7 相关数据的文件档案啰! 好了,那么万一我真的忘记了下达数字,只有输入『 man man 』时,那么取出的数据到底是 1 还是 7 啊? 这个就跟搜寻的顺序有关了。搜寻的顺序是记录在 /etc/man.conf 这个配置文件当中, 先搜寻到的那个说明档,就会先被显示出来! 一般来说,通常会先找到数字较小的那个啦!因为排序的关系啊!所以, man man 会跟 man 1 man 结果相同! 这样说,可以明白了吗?!

除此之外,我们还可以利用『关键词』找到更多的说明文件数据喔!例如:

[root@linux ~]# man-k man
. [builtins]         (1)  - bash built-in commands, seebash(1)
alias [builtins]     (1)  - bash built-in commands, seebash(1)
........(中间省略)....
xsm                  (1x)  - X Session Manager
zshall               (1)  - the Z shell meta-manpage
zshbuiltins          (1)  - zsh built-in commands
zshzle               (1)  - zsh command line editor

看到了吧!很多对吧!因为这个是利用关键词将说明文件里面只要含有man 那个字眼的(不见得是完整字符串) 就将他取出来!很方便吧! ^_^

事实上,还有两个指令与man page 有关呢!而这两个指令是 man 的简略写法说~ 就是这两个:

[root@linux~]# whatis  [指令或者是数据]   <==相当于 man -f [指令或者是数据]
[root@linux ~]# apropos [指令或者是数据]   <==相当于 man -k [指令或者是数据]

Linux man --显示在线手册页相关推荐

  1. 使用man在线手册页

    #man  -k   函数         #man  返回的数字  函数 # man -k file | grep umask 要查看linux下的函数umask 可以使用man,例如 # man  ...

  2. Linux下dislocate命令用法,在 Linux 中遨游手册页的海洋 | Linux 中国

    原标题:在 Linux 中遨游手册页的海洋 | Linux 中国 Linux 系统上的手册页可以做的不仅仅是提供特定命令的信息.它们可以帮助你发现你没有意识到的命令. https://linux.cn ...

  3. cgroups(7)— Linux中文手册页

    CGROUPS(7)Linux程序员手册CGROUPS(7) NAME         顶部 cgroups-Linux控制组 说明         顶部 控制组(通常称为cgroup)是Linux内 ...

  4. 如何在Linux上创建手册页

    Fatmawati Achmad Zaenuri/Shutterstock Fatmawati Achmad Zaenuri / Shutterstock Want your new Linux pr ...

  5. linux安装tldr 中文,分享|TLDR 页:Linux 手册页的简化替代品

    在终端上使用各种命令执行重要任务是 Linux 桌面体验中不可或缺的一部分.Linux 这个开源操作系统拥有丰富的命令,任何用户都无法全部记住所有这些命令.而使事情变得更复杂的是,每个命令都有自己的一 ...

  6. Linux/Unix 如何查看 man 搜索到的手册页(manual page)的位置及复制手册页的内容

    文章目录 命令 man 是如何搜索手册页的? 如何查看手册页所在的路径 通过管道输出给 vim 命令 man 是如何搜索手册页的? man uses a sophisticated method of ...

  7. linux怎么显示第三个数据,从零开始的linux 第三章

    从零开始的linux 第三章 同学们~起床咯~~(小编拿着喇叭在宿舍楼下喊道) 美好的一天从...从赞小编的博客开始~~ (↓看见小编的同学们) 什么!?你们对着可爱的小编说什么!?再说一遍!!? 同 ...

  8. 谷歌地球使用手册_如何使用手册页:比Google搜索更快

    谷歌地球使用手册 养成使用谷歌搜索您想了解的关于Linux中的命令或操作的习惯是很容易的,但是我认为还有更好的东西:生动活泼,完整的参考资料, 手册页 ,这是手册页的缩写. 手册页的历史可以追溯到Li ...

  9. linux7怎么查看rsync状态,linux – Rsync显示单个文件的进度

    这可能就是你所追求的. % rsync -avvz --times --stats --checksum --human-readable --acls \ --itemize-changes --p ...

  10. 没有 XXX 的手册页条目

    没有 XXX 的手册页条目 最近在使用Linux中的vim编辑器进行多线程程序的实现,在使用man命令进行函数定义的查看.提示 没有 XXX 的手册页条目? 1.需要执行以下命令: sudo apt- ...

最新文章

  1. 如何实现一个连接池?一文带你深入浅出,彻底搞懂!
  2. mustache 渲染文本一直渲染不出来
  3. Python面向对象编程:类继承和其衍生术语
  4. leetcode 144. Binary Tree Preorder Traversal
  5. es6-变量的解构赋值
  6. network中的请求信息,headers中的每一项分别是什么意义?
  7. file_table.c 文件分析 linux1_0\linux\fs\file_table.c
  8. Oracle RAC更改VIP IP地址_2节点的实验
  9. pip 安装 rdkit
  10. cesium 百度地图_Cesium专栏-热力图(附源码下载)
  11. 三边测量定位算法C语言实现
  12. Linux 进程查看命令 ps top htop dstat
  13. python怎么取共轭_python print出共轭复数的方法详解
  14. 【爬虫】王者荣耀爬取英雄高清4K图片
  15. 优秀公众号推荐 STM32与FPGA资料整理 windows小工具推荐
  16. elixir mix 简介
  17. 如何下载编译Linux下RJMCMCMT1D(可逆跳跃马尔科夫链门特卡罗一维大地电磁反演)开源软件
  18. 在Nginx中让所有HTTP请求转发到HTTPS
  19. u盘正常接入后计算机无法看到,U盘连接XP系统电脑能识别但不显示怎么办?
  20. 网络斗地主游戏的完整设计与实现(三)入口存储过程详解,理解动态调用存储过程的原理

热门文章

  1. day01 -Web API介绍—DOM 介绍—获取元素—事件基础—操作元素—排他操作—自定义属性操作—节点操作—案例:动态生成表格—创建元素的三种方式(经典面试题)
  2. “做我女朋友好吗?”vbs源码
  3. python3 列表list 内置函数
  4. STM32库内程序一些好的编程思路、方法及好的程序
  5. 程序员是如何从小白做到年薪百万
  6. 我在垃圾场捡到一个黑匣子,拆给大家看看
  7. 先进事迹计算机维护与维修,汽车维修工先进事迹
  8. c语言生成exe文件的作用,c语言怎么生成exe文件
  9. leaflet快速渲染聚合矢量瓦片(附源码下载)
  10. 2022年贵州省职业院校技能大赛中职组网络安全赛项规程