Manpage – Difference Between `man` and `man (#)`

manpage

Just saw someone referencing man 7 regex on Stackoverflow. I tried man regex and got very similar output – there appear to be slight differences.

So what is this magical number 7? Searching man 7 unix on Google gives me more mysterious results like UNIX(7)…

Best Answer

About UNIX(7)

To answer your question of "UNIX(7)", this is standard convention of saying "The man page for UNIX in section 7 (miscellaneous)".

To open a page like init(8), you would use this command: man 8 init.


man regex vs man 7 regex

To answer your question of the 'subtle differences' between man regex and man 7 regex:

man by default opens the page with the lowest section number. In this case, it is section 3 (Library calls). Opening the page from section 7 (Miscellaneous) is quite different.

Pages in different sections address different things, though in this case they are similar, consider apt:

man -f apt:

apt (8)              - Advanced Package Tool
apt (1)              - annotation processing tool

In this example, apt from section 8 (System administration commands) is completely unrelated to the page from section 1 (Executable programs or shell commands).

For future reference, use man -f PAGE_NAME to locate all pages with that name in all sections. You can then open a page from the section you want with man SECTION PAGE_NAME.

Manpage sections

The various page sections are as follows and can be found from man man:

  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 conventions), e.g. man(7), groff(7)
  8. System administration commands (usually only for root)
  9. Kernel routines [Non standard]