联机帮助页中 Unix 命令名称后面显示的括号中的数字是什么意思?

发布于 2024-07-05 22:00:41 字数 108 浏览 11 评论 0原文

例如:man(1)find(3)updatedb(2)

括号(英式“方括号”)中的数字是什么意思?

For example: man(1), find(3), updatedb(2)?

What do the numbers in parentheses (Brit. "brackets") mean?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

不交电费瞎发啥光 2024-07-12 22:00:41

这是命令的手册页所分配到的部分。

它们被分为

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

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

为了访问“foo(5)”给出的手册页,请运行:

man 5 foo

It's the section that the man page for the command is assigned to.

These are split as

  1. General commands
  2. System calls
  3. C library functions
  4. Special files (usually devices, those found in /dev) and drivers
  5. File formats and conventions
  6. Games and screensavers
  7. Miscellanea
  8. System administration commands and daemons

Original descriptions of each section can be seen in the Unix Programmer's Manual (page ii).

In order to access a man page given as "foo(5)", run:

man 5 foo
人生戏 2024-07-12 22:00:41

该命令的部分记录在手册中。 各部分的列表记录在人类手册中。 例如:

man 1 man
man 3 find

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

The section the command is documented in the manual. The list of sections is documented on man's manual. For example:

man 1 man
man 3 find

This is useful for when similar or exactly equal commands exist on different sections

心安伴我暖 2024-07-12 22:00:41

部分编号之所以重要,是因为许多年前磁盘空间比现在更成为一个问题,这些部分可以单独安装。

例如,许多系统只安装了 1 和 8。 如今,人们倾向于在谷歌上查找命令。

The reason why the section numbers are significant is that many years ago when disk space was more of an issue than it is now the sections could be installed individually.

Many systems only had 1 and 8 installed for instance. These days people tend to look the commands up on google instead.

紅太極 2024-07-12 22:00:41

正如 @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.


2. 男人

假设您正在 Google 上搜索 Linux 命令。 您可以在线找到OPEN(2) pg: open(2) — Linux 手册页

要在电脑上的手册页中查看此内容,只需输入 man 2 open 即可。

对于 FOPEN(3) 使用man 3 fopen

3. man; intro

要阅读某个部分的介绍页面,请输入 man; intro,例如 man 1 introman 2 introman 7 intro 等。

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

--Man-- next: intro(8) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]

请注意,该部分的顺序是 < code>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)

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

相关:

  1. Google 搜索“ linux 函数后面括号中的数字是什么意思?"
  2. 超级用户:Unix 命令或 C 函数后面的括号和数字是什么意思?
  3. Unix 和 Linux Linux:手册页中的数字是什么意思?

As @Ian G says, they are the man page sections. Let's take this one step further though:

1. See the man page for the man command with man man, and it shows the 9 sections as follows:

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.


2. man <section_num> <cmd>

Let's imagine you are Googling around for Linux commands. You find the OPEN(2) pg online: open(2) — Linux manual page.

To see this in the man pages on your pc, simply type in man 2 open.

For FOPEN(3) use man 3 fopen, etc.

3. man <section_num> intro

To read the intro pages to a section, type in man <section_num> intro, such as man 1 intro, man 2 intro, man 7 intro, etc.

To view all man page intros in succession, one-after-the-other, do man -a intro. The intro page for Section 1 will open. Press q to quit, then press Enter to view the intro for Section 8. Press q to quit, then press Enter to view the intro for Section 3. Continue this process until done. Each time after hitting q, it'll take you back to the main terminal screen but you'll still be in an interactive prompt, and you'll see this line:

--Man-- next: intro(8) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]

Note that the Section order that man -a intro will take you through is:

  1. Section 1
  2. Section 8
  3. Section 3
  4. Section 2
  5. Section 5
  6. Section 4
  7. Section 6
  8. Section 7

This search order is intentional, as the man man page explains:

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)

Why did they choose this order? I don't know (please answer in the comments if you know), but just realize this order is correct and intentional.

Related:

  1. Google search for "linux what does the number mean in parenthesis after a function?"
  2. SuperUser: What do the parentheses and number after a Unix command or C function mean?
  3. Unix & Linux: What do the numbers in a man page mean?
仙女 2024-07-12 22:00:41

另请注意,在其他 UNIX 上,指定该部分的方法有所不同。 以Solaris 为例,它是:

man -s 1 man

Note also that on other unixes, the method of specifying the section differs. On solaris, for example, it is:

man -s 1 man
薄荷港 2024-07-12 22:00:41

它指示在手册页中找到该命令的部分。 man 命令上的 -s 开关可用于将搜索限制为某些部分。

当您查看手册页时,左上角会给出该部分的名称,例如:

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

因此,如果您尝试查找 C 函数并且不想意外看到共享相同名称的用户命令的页面,则可以执行“man -s 3C ...”

It indicates the section of the man pages the command is found in. The -s switch on the man command can be used to limit a search to certain sections.

When you view a man page, the top left gives the name of the section, e.g.:

User Commands printf(1)
Standard C Library Functions printf(3C)

So if you are trying to look up C functions and don't want to accidentally see a page for a user command that shares the same name, you would do 'man -s 3C ...'

時窥 2024-07-12 22:00:41

Wikipedia 有关手册部分的详细信息:

  1. 通用命令
  2. 系统调用
  3. 库函数,特别是 C 语言标准库
  4. 特殊文件(通常是设备,位于 /dev 中)和驱动程序
  5. 文件格式和约定
  6. 游戏和屏幕保护程序
  7. 杂项
  8. 系统管理命令和守护程序

Wikipedia details about Manual Sections:

  1. General commands
  2. System calls
  3. Library functions, covering in particular the C standard library
  4. Special files (usually devices, those found in /dev) and drivers
  5. File formats and conventions
  6. Games and screensavers
  7. Miscellanea
  8. System administration commands and daemons
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文