`

我使用过的Linux命令之man - 显示在线手册页

阅读更多

我使用过的Linux命令之man - 显示在线手册页

本文链接:http://codingstandards.iteye.com/blog/971078   (转载请注明出处)

用途说明

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、Administrative Commands (管理员命令)

 

使用示例

示例一 显示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] [-M pathlist] [-P pager] [-B browser] [-H
       htmlpager] [-S section_list] [section] name ...

DESCRIPTION
       man formats and displays the on-line manual pages.  If you specify section, man only looks in that  section  of
       the  manual.  name is normally the name of the manual page, which is typically the name of a command, function,
       or file.  However, if name contains a slash (/) then man interprets it as a 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 man pages.  Separate the directories with colons.  An
              empty list is the same as not specifying -M at all.  See SEARCH PATH FOR MANUAL 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 HTML files.  This option overrides the BROWSER environment variable. By
              default, man uses /usr/bin/less-is,

       -H     Specify a command that renders HTML files as text.  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 option overrides the MANSECT environ-
              ment variable.

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

:q
[root@jfht ~]#

 

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

[root@jfht ~]# man printf
PRINTF(1)                        User Commands                       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’s Manual                 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 output according 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() and vsnprintf() write to the character string
       str.

       The functions vprintf(),  vfprintf(),  vsprintf(),  vsnprintf()  are  equivalent  to  the  functions  printf(),
       fprintf(),  sprintf(),  snprintf(), respectively, except that they are 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 string that specifies how subsequent argu-
       ments (or arguments accessed via the variable-length argument facilities of stdarg(3)) are converted  for  out-
       put.

   Return value
       Upon  successful  return,  these  functions return the number of characters printed (not including the trailing
       ’\0’ used to end output to strings).  The functions snprintf() and vsnprintf() do  not  write  more  than  size
       bytes  (including  the  trailing ’\0’).  If the output was truncated due to this limit then the return value is
       the number of characters (not including the trailing ’\0’) which would have been 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 signal processes 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 or report 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 ~]#

 

问题思考

1. manpage是由哪些部分组成的?

2. manpage的语法规则如何,以及如何变成man手册页?

 

相关资料

【1】飞诺网 linux man的使用
http://dev.firnow.com/course/6_system/linux/Linuxjs/2008109/149569.html
【2】Linux公社 Linux man章节分类以及查询
http://www.linuxidc.com/Linux/2010-12/30881.htm
【3】三二一@小鱼 (9)linux man usage
http://blog.csdn.net/livelylittlefish/archive/2009/08/26/4487971.aspx
【4】我使用过的Linux命令之apropos - 根据关键字搜索命令
http://codingstandards.iteye.com/blog/776024
【5】我使用过的Linux命令之help - 显示Bash内建命令的帮助信息
http://codingstandards.iteye.com/blog/804620
【6】我使用过的Linux命令之type - 显示命令的类型
http://codingstandards.iteye.com/blog/831504

 

返回 我使用过的Linux命令系列总目录

 

1
1
分享到:
评论

相关推荐

    Linux中文man离线手册.chm

    Linux中文man离线手册.chm

    中文Linux Man 文档

    中文Linux Man 文档 ac--输出用户连接时间  access--确定文件是否可以存取访问  ali--list mail aliases  apm--查询高级电源管理(APM)BIOS  apropos--search the whatis database for strings  at-- ...

    linux命令自定义man手册

    这是一个整合了一百多个常用命令的脚本,并且增加很多命令的注释和常用的命令格式,因此可以称作自定义man手册,将其放在/bin目录下,加上执行权限,即可随便查看命令的相关注释,比如sed和awk,记录了大量命令的...

    Linux-man中文手册.chw

    linux必备命令手册

    一些linux常用命令的man手册 英文 pdf

    一些linux常用命令的man手册 英文 pdf

    linux man 手册(2010-10-4更新) 3.28

    将man-pages-3.28.tar.gz复制在Linux下的临时目录,解压后(命令为:tar -xvzf man-pages-3.28.tar.gz -C ./),之后进入解压后的目录运行:make install 即可. 验证的话随便man一个系统函数看下最后的日期即可 在我的...

    Linux所有命令的中文版手册

    Linux所有命令的中文版手册 来自CMPP &lt;http://cmpp.linuxforum.net&gt; 的中文手册页 目录结构的说明如下: debian:存放制作debian打包需要的所有内容 DOCS: 除了README 和README.GB, COPYING 之外的所有文档。 ...

    Linux命令速查手册-_美_-Scott-Granneman

    Linux命令速查手册-_美_-Scott-Granneman

    Linux man命令汉化

    Linux 提供了丰富的帮助手册,当你需要查看某个命令的参数时不必到处上网查找, 只要 man 一下即可。 Linux 的 man 手册共有以下几个章节: 代号 代表內容 1 使用者在 shell 中可以操作的指令或可执行档 2 系統核心...

    linux中文man手册安装

    2. 为了不抵消man,我们新建cman命令作为中文查询 [root@localhost man1]# cd ~ [root@localhost ~]# echo "alias cman='man -M /usr/local/zhman/share/man/zh_CN' " &gt;&gt;.bash_profile [root@localhost ~]# source ...

    Linux man中文参考手册.rar

    Linux man中文参考手册,涉及到Linux API和Linux命令所有的详细介绍。

    man中文手册安装

    学习linux离不开学习那些命令,学习命令看man page手册是好方法。 但原版的man page是英文版的,对于像我这样英语还很菜的新手来说是不小的难题。 就找了这个中文版的man手册 安装: 1.下载中文man压缩包 ...

    linux_man.zip_linux命令手册

    linux 的命令手册,是一本相当OK的手册

    man-pages-hi:将手册页翻译成印地语-开源

    Linux中总共有8个手册页模块,从我们的项目开始,我们就动手尝试了将man1模块从man1模块转换为man1模块,而man1模块是Linux手册页的8个模块之一。 传统上,手册页部分的定义如下:man1-命令(程序)man2-系统调用...

    linux命令大全(chm)

    Linux命令大全是指包含了Linux操作系统中所有可用命令的完整列表或手册。它通常包括了Linux系统中的核心命令、系统管理命令、文件和目录操作命令、网络命令、软件安装和配置命令等。 Linux命令大全可以作为参考手册...

    最全Linux常用命令大全

    Linux命令大全是指包含了Linux操作系统中所有可用命令的完整列表或手册。它通常包括了Linux系统中的核心命令、系统管理命令、文件和目录操作命令、网络命令、软件安装和配置命令等。 Linux命令大全可以作为参考手册...

    绝对经典--最完整的Linux开发手册(一)

    该文档是Linux下的man文档做成。chm格式。共80多M。 其中,所有的“参见”部分都有链接,很方便开发者浏览相关的内容。 该chm文件支持全文搜索和标题搜索。如果你不熟悉Linux下文档的布局,可以直接 使用“搜索”-&gt;...

    绝对经典--最完整的Linux开发手册(三)

    该文档是Linux下的man文档做成。chm格式。共80多M。 其中,所有的“参见”部分都有链接,很方便开发者浏览相关的内容。 该chm文件支持全文搜索和标题搜索。如果你不熟悉Linux下文档的布局,可以直接 使用“搜索”-&gt;...

    Linuxman CHM 格式

    Linuxman CHM 格式文件 Linux man 命令详细介绍 Linux学习好帮手 值得收藏的Linux命令速查手册

    使用man手册页.docx

    使用man手册页 Linux提供一种集中手册页文档机制 查看及切换目录 一级目录 通配符 alias命令

Global site tag (gtag.js) - Google Analytics