例如:
man(1)
,find(3)
,updatedb(2)
?括号中的数字代表什么意思(英国称之为“括号”)?man(1)
,find(3)
,updatedb(2)
?括号中的数字代表什么意思(英国称之为“括号”)?这是分配给命令的手册页部分。
它们被分为:
每个部分的原始描述可以在Unix程序员手册(第二页)中查看。
要访问名为“foo(5)”的手册页,请运行:
man 5 foo
man foo.5
同样有效,并且在你必须在上一个命令给出错误页面后指定页码时更容易添加页码。 - 12431234123412341234123命令所在的章节在手册中有详细介绍。章节列表在man手册中有记录。例如:
man 1 man
man 3 find
当不同部分存在相似或完全相等的命令时,这很有用。
章节编号之所以重要,是因为在很多年前,磁盘空间比现在更加紧缺,各个章节可以单独安装。
例如,许多系统仅安装了1和8。如今人们倾向于通过谷歌查找命令。
正如@Ian G所说,它们是man手册的章节。然而,让我们更深入地了解一下:
man man
命令查看man手册,并显示9个章节如下:DESCRIPTION
man is the system's manual pager. Each page argument given
to man is normally the name of a program, utility or func‐
tion. The manual page associated with each of these argu‐
ments 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 sec‐
tions following a pre-defined order ("1 n l 8 3 2 3posix 3pm
3perl 5 4 9 6 7" by default, unless overridden by the SEC‐
TION directive in /etc/manpath.config), 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 fol‐
lowed by the types of pages they contain.
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conven‐
tions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
A manual page consists of several sections.
man <section_num> <cmd>
假设你正在搜索Linux命令,你找到了在线的OPEN(2)
页面: open(2) — Linux 手册页。
要在你的电脑上查看man页面,请输入man 2 open
。
对于FOPEN(3)
,使用man 3 fopen
等。
man <section_num> intro
要阅读每个部分的介绍页面,请输入man <section_num> intro
,例如man 1 intro
、man 2 intro
、man 7 intro
等。
要依次查看所有man页面的介绍页面,请执行man -a intro
。将打开第一个部分的介绍页面,按q退出后,按Enter查看第二个部分的介绍页面,以此类推。每次按下q后,将回到主终端屏幕,但您仍将处于交互式提示状态,并且将看到此行:
--Man-- next: intro(8) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
请注意,man -a intro
命令列出的章节顺序如下:
man man
页面所解释的那样:The default action is to search in all of the available sections follow‐
ing a pre-defined order ("1 n l 8 3 2 3posix 3pm 3perl 5 4 9 6 7" by default, unless overrid‐
den by the SECTION directive in /etc/manpath.config)
他们为什么选择这个顺序?我不知道(如果您知道,请在评论中回答),但是请注意这个顺序是正确和有意的。
+1
- Manuel Jordanman -s 1 man
该指示命令所在的man手册部分。man命令的-s开关可以用于将搜索限制为某些部分。
当您查看man页面时,左上角显示了部分名称,例如:
用户命令 printf(1)
标准C库函数 printf(3C)
因此,如果您想查找C函数并且不想意外地看到与其同名的用户命令页面,则应执行'man -s 3C ...'