因此,例如,当我输入时,man ls
我看到LS(1)
. 但是,如果我输入man apachectl
我会看到APACHECTL(8)
,如果我输入man cd
我最终会看到cd(n)
.
我想知道括号中数字的意义是什么(如果有的话)。
Mic*_*zek 650
该数字对应于该页面来自手册的哪个部分;1 是用户命令,而 8 是系统管理员的东西。man 本身的手册页 ( man man
) 对其进行了解释并列出了标准的:
MANUAL SECTIONS
The standard sections of the manual include:
1 User Commands
2 System Calls
3 C Library Functions
4 Devices and Special Files
5 File Formats and Conventions
6 Games et. al.
7 Miscellanea
8 System Administration tools and Daemons
Distributions customize the manual section to their specifics,
which often include additional sections.
Run Code Online (Sandbox Code Playgroud)
有些术语在不同的部分有不同的页面(例如,printf
作为命令出现在第 1 部分,作为stdlib
函数出现在第 3 部分);在这种情况下,您可以将部分编号传递到man
页面名称之前以选择您想要的页面,或用于man -a
连续显示每个匹配的页面:
$ man 1 printf
$ man 3 printf
$ man -a printf
Run Code Online (Sandbox Code Playgroud)
您可以判断一个术语属于哪些部分man -k
(相当于apropos
命令)。它也会进行子字符串匹配(例如,它会sprintf
在您运行时显示man -k printf
),因此您需要使用^term
来限制它:
$ man -k '^printf'
printf (1) - format and print data
printf (1p) - write formatted output
printf (3) - formatted output conversion
printf (3p) - print formatted output
printf [builtins] (1) - bash built-in commands, see bash(1)
Run Code Online (Sandbox Code Playgroud)
请注意,该部分有时可以包括子部分(例如,p
in1p
和3p
above)。该p
小节是针对 POSIX 规范的;该x
小节用于 X Window 系统文档。
Kei*_*thB 65
这些章节编号的历史可以追溯到Thompson 和 Ritchie 在 1971 年的原始Unix 程序员手册。
原来的部分是
Bab*_*yan 39
konqueror 还描述了非标准部分:(感谢@greg0ire 的想法)
0 Header files
0p Header files (POSIX)
1 Executable programs or shell commands
1p Executable programs or shell commands (POSIX)
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
3n Network Functions
3p Perl Modules
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines
l Local documentation
n New manpages
Run Code Online (Sandbox Code Playgroud)
Sha*_*dur 17
从man
联机帮助页:
The table below shows the section numbers of the manual followed 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]
Run Code Online (Sandbox Code Playgroud)
至于为什么他们像这样分开——有一些重叠。根据您的意思,某些联机帮助页存在于多个部分中。
例如,man crontab
与man 5 crontab
--比较可能是后者是您要查找的那个。
通常,手册页是通过用括号括起来的部分作为后缀来引用的,例如:
read(2)
Run Code Online (Sandbox Code Playgroud)
这种风格有两个主要优点:
手册页按部分组织,例如,第 1 部分包含所有用户命令手册页,第 2 部分包含系统调用的所有手册页,第 3 部分包含库函数等。
在命令行上,如果您没有明确指定您将获得第一个匹配手册页的部分,则采用默认的部分遍历顺序,例如:
$ man read
Run Code Online (Sandbox Code Playgroud)
BASH_BUILTINS(1)
在 Fedora 上显示。在哪里
$ man 2 read
Run Code Online (Sandbox Code Playgroud)
显示read()
系统调用的手册页。
请注意,该部分的位置规范是不可移植的——例如,在 Solaris 上,您可以像这样指定它:
$ man -s 2 read
Run Code Online (Sandbox Code Playgroud)
通常,man man
还会列出一些可用的部分。但不一定是全部。为了列出所有可用的部分,可以列出默认 man 路径或环境变量中列出的所有目录的子目录$MANPATH
。例如在安装了一些开发包的 Fedora 23 系统上/usr/share/man
有以下子目录:
cs es id man0p man2 man3x man5x man7x man9x pt_BR sk zh_CN
da fr it man1 man2x man4 man6 man8 mann pt_PT sv zh_TW
de hr ja man1p man3 man4x man6x man8x pl ro tr
en hu ko man1x man3p man5 man7 man9 pt ru zh
Run Code Online (Sandbox Code Playgroud)
带有man
前缀的目录代表每个部分 - 而其他目录包含翻译的部分。因此,要获取非空部分的列表,可以发出如下命令:
$ find /usr/share/man -type f | sed 's@^.*/man\(..*\)/.*$@\1@' \
| sort -u | column
0p 1p 3 4 6 8
1 2 3p 5 7
Run Code Online (Sandbox Code Playgroud)
(以 结尾的部分p
是 POSIX 手册页)
要查看另一种语言的手册页(如果可用),可以设置与语言相关的环境变量,例如:
$ LC_MESSAGES=de_DE man read
Run Code Online (Sandbox Code Playgroud)
此外,每个部分都应该有一个名为 的介绍手册页intro
,例如可以通过以下方式查看:
$ man 2 intro
Run Code Online (Sandbox Code Playgroud)
SVr4 的定义是:
1 User Commands
2 System Calls
3 library Functions
4 File Formats
5 Standards, Environment and Macros (e.g. man(5))
6 Games and Demos
7 Device and Network Interfaces, Special Files
8 Maintenance Procedures
9 Kernel and Driver entry points and structures
Run Code Online (Sandbox Code Playgroud)
这些是“遗传”UNIX 的实际编号。POSIX 没有定义数字。