在联机帮助页中的Unix命令名后,括号中的数字是什么意思?

duc*_*lip 470 unix linux command-line manpage

例如:man(1),find(3),updatedb(2)?括号中的数字(英文"括号")是什么意思?

Ian*_*n G 448

这是分配命令的手册页的部分.

这些被拆分为

  1. 一般命令
  2. 系统调用
  3. C库函数
  4. 特殊文件(通常是设备,在/ dev中找到的)和驱动程序
  5. 文件格式和约定
  6. 游戏和屏保
  7. 杂记
  8. 系统管理命令和守护程序

可以在Unix程序员手册(第ii页)中查看每个部分的原始描述.

  • 信息的关键位:访问给定为"foo(5)"的手册页:`man 5 foo` (108认同)
  • `man foo.5` 也适用于某些(大多数,所有?)系统,并且当您必须在最后一个命令给出错误页面后指定数字时,可以更轻松地添加数字。 (6认同)
  • [这是一个没有破坏的链接](http://www.tuhs.org/Archive/Distributions/Research/Dennis_v5/v5man.pdf) (2认同)
  • 该链接具有相同的列表,但是是所述手册的 v5 版本。我冒昧地将答案的链接更新为指向互联网档案馆的链接,其中包含原始答案似乎链接到的 v7 版本(基于 URL)。 (2认同)

Vin*_*vic 75

该命令的部分记录在手册中.部分列表记录在人工手册中.例如:

man 1 man
man 3 find
Run Code Online (Sandbox Code Playgroud)

当在不同部分上存在类似或完全相同的命令时,这非常有用

  • 在"过去的日子"中,部分编号对应于手册版的硬拷贝版本所在的活页夹. (96认同)

小智 47

部分编号很重要的原因是多年前磁盘空间问题比现在更多,这些部分可以单独安装.

例如,许多系统仅安装了1和8.这些天人们倾向于在谷歌上查看命令.


Gab*_*les 19

正如@Ian G 所说,它们是手册页部分。不过,让我们更进一步:

1.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.


Run Code Online (Sandbox Code Playgroud)

2. man <section_num> <cmd>

假设您正在 Google 上搜索 Linux 命令。您可以OPEN(2)在线找到pg:http : //man7.org/linux/man-pages/man2/open.2.html

要在您电脑的手册页中看到这一点,只需输入man 2 open.

用于FOPEN(3)使用man 3 fopen等。

3. man <section_num> intro

要阅读介绍页面到部分,在man <section_num> intro,如man 1 introman 2 introman 7 intro等。

要依次查看所有手册页介绍,请执行man -a intro。第 1 部分的介绍页面将打开。按q退出,然后按Enter查看第 8 部分的介绍。按q退出,然后按Enter查看第 3 部分的介绍。继续此过程直到完成。每次点击 后q,它都会带您回到主终端屏幕,但您仍将处于交互式提示中,您将看到以下行:

--Man-- next: intro(8) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
Run Code Online (Sandbox Code Playgroud)

请注意,man -a intro将带您完成的部分顺序是:

  1. 第 1 节
  2. 第 8 节
  3. 第 3 节
  4. 第 2 节
  5. 第 5 节
  6. 第 4 节
  7. 第 6 节
  8. 第 7 节

这个搜索顺序是有意的,正如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)
Run Code Online (Sandbox Code Playgroud)

他们为什么选择这个顺序?我不知道(如果你知道,请在评论中回答),但只是意识到这个顺序是正确和有意的。

有关的:

  1. Google 搜索“linux 函数后括号中的数字是什么意思?” - https://www.google.com/search?q=linux+what+does+the+number+mean+in+括号+after+a+function%3F&oq=linux+what+does+the+number+mean +in+括号+after+a+function%3F&aqs=chrome..69i57j69i64.9867j0j7&sourceid=chrome&ie=UTF-8
  2. https://superuser.com/questions/297702/what-do-the-parentheses-and-number-after-a-unix-command-or-c-function-mean
  3. https://unix.stackexchange.com/questions/3586/what-do-the-numbers-in-a-man-page-mean

  • 非常有用的信息,不知道为什么投反对票,但你有我的+1。 (2认同)
  • 出色的补充 - 当之无愧的“+1” (2认同)

TRE*_*REE 9

另请注意,在其他unix上,指定节的方法不同.例如,在solaris上,它是:

man -s 1 man
Run Code Online (Sandbox Code Playgroud)


Dav*_*sta 7

它指示命令所在的手册页部分.man命令的-s开关可用于限制搜索某些部分.

查看手册页时,左上角会显示该节的名称,例如:

用户命令printf(1)
标准C库函数printf(3C)

因此,如果您正在尝试查找C函数并且不想意外地看到共享相同名称的用户命令的页面,那么您将执行'man -s 3C ...'