TIL: Number in man page titles (e.g. sleep(3))

If you do Linux systems programming, you will have likely pored over man pages, either on the command line or, my personal preference, using the excellent man7.org or linux.die.net. I’ve always seen the numbers in sleep(3) and read(2) and idly wondered what they meant, but never actually bothered to look them up. That is, until a review comment on a pull request: // Behaves like man 2 basename reviewer: nit: it’s not a syscall, so “man 2” is incorrect So I looked it up. The answer was in the man(1) page (also accessible via the delightful man man command): 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) (... less common section numbers) So my colleague was right and the code should have read // behaves like man 3 basename as basename(3) is a libc library call.

Lalit Maganti

> (... less common section numbers)

One very important section number is 5 - it's for file formats. So if you forget the crontab format, you need to invoke `man 5 crontab` to read about it.

... because if you do `man crontab` you get section 1, which does not document the crontab fields.

That is incredibly stupid. A documentation system designed by someone who doesn't understand how people use documentation.

If man was designed by someone with any taste at all it would at least give you a menu to select (1) crontab command, (5) crontab file format. Maybe we need a rewrite in Rust to fix that.

> If man was designed by someone with any taste at all it would at least give you a menu [...]

My goodness. Man was written on a paper teletype.

And since man pages could take minutes to print out, if you needed one you'd tear that section of paper off and keep it in a binder for future (and faster) reference.