手册页标题中的数字,例如 sleep(3)
发布: (2026年4月6日 GMT+8 17:39)
2 分钟阅读
原文: Hacker News
Source: Hacker News
概述
如果你从事 Linux 系统编程,可能已经在命令行上或我个人更喜欢的优秀站点 man7.org 或 linux.die.net 上仔细阅读过 man 手册页。
我一直看到 sleep(3) 和 read(2) 中的数字,偶尔好奇它们的含义,但从未真正去查过——直到一次拉取请求的审查评论:
// Behaves like man 2 basename
// reviewer: nit: it’s not a syscall, so “man 2” is incorrect手册页章节编号
man(1) 页面(也可以通过 man man 访问)包含一张将章节编号映射到对应页面类型的表格:
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
... less common section numbers因此正确的评论应该是:
// behaves like man 3 basename因为 basename(3) 是一个 libc 库调用。
后缀
除了数字章节外,还可以附加各种字母后缀以表示特殊类别:
p– POSIX 手册页,例如free(3p)x– X 文档,例如ncurses(3x)
我很尴尬地承认,我使用手册页已经多年,却直到今天才学到这些。