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)...
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
vsman 7 regex
To answer your question of the 'subtle differences' between
man regex
andman 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
: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 withman SECTION PAGE_NAME
.Manpage sections
The various page sections are as follows and can be found from
man man
:The section numbers
man
will show the manpage from any section,man 7
will show the manpage from section 7. So, here 7 refers to the section of the particular command for which you are looking for the manual page.A section, if provided, will direct man to look only in that section of the manual.
The sections
See the following table for the section numbers of the manual followed by the types of pages they contain.
Commands in more than one section
In most of the cases you will want to use the
man
command without additional n. However, in some cases a command will appear in more than one section. For example if you issue the commandman open
, you get the man page for openvt from section 1. But if you need to see the man page for open as a C (or system call, as per the above table) command, you need to issueman 2 open
.A very similar example will be
man printf
andman 3 printf
. Please issue the commands and see for yourself the difference in output.Your issue of
man 7 unix
(UNIX(7))So, that UNIX(7) means that it belongs to section 7.
Which section will be shown by default if I do not provide a section number?
The default action is to search in all of the available sections, following a pre-defined order and to show only the first page found, even if page exists in several sections.
How do I know the section number of a command?
Should you need to find out what sections a term/command falls in with
man -k
(equivalent to the apropos command). So,man -k printf
will search the short descriptions and manual page names for the keyword printf as regular expression. Print out any matches. (Equivalent toapropos -r printf
). Issue the command, see the ton you get. If need to avoid substring matches, (e.g. it will show sprintf if you runman -k printf
), so you need to use^term
to limit it, as below,Related command
A related command is
apropos
as indicated above, which searches the manual page names and descriptions. If you are not sure which manual page you are looking for but have a general idea, use this command.