So, for example, when I type
man ls I see
LS(1). But if I type
man apachectl I see
APACHECTL(8) and if I type
man cd I end up with
I'm wondering what the significance of the numbers in the parentheses are, if they have any.
The number corresponds to what section of the manual that page is from; 1 is user commands, while 8 is sysadmin stuff. The man page for man itself (
man man) explains it and lists the standard ones:
MANUAL SECTIONS The standard sections of the manual include: 1 User Commands 2 System Calls 3 C Library Functions 4 Devices and Special Files 5 File Formats and Conventions 6 Games et. al. 7 Miscellanea 8 System Administration tools and Daemons Distributions customize the manual section to their specifics, which often include additional sections.
There are certain terms that have different pages in different sections (e.g.
printf as a command appears in section 1, as a
stdlib function appears in section 3); in cases like that you can pass the section number to
man before the page name to choose which one you want, or use
man -a to show every matching page in a row:
$ man 1 printf $ man 3 printf $ man -a printf
You can tell what sections a term falls in with
man -k (equivalent to the
apropos command). It will do substring matches too (e.g. it will show
sprintf if you run
man -k printf), so you need to use
^term to limit it:
$ man -k '^printf' printf (1) - format and print data printf (1p) - write formatted output printf (3) - formatted output conversion printf (3p) - print formatted output printf [builtins] (1) - bash built-in commands, see bash(1)
konqueror also describes non-standard sections: (thanks to @greg0ire for the idea)
0 Header files 0p Header files (POSIX) 1 Executable programs or shell commands 1p Executable programs or shell commands (POSIX) 2 System calls (functions provided by the kernel) 3 Library calls (functions within program libraries) 3n Network Functions 3p Perl Modules 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 l Local documentation n New manpages
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) 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]
As to why they're separate like that -- there's some overlap. Certain manpages exist in more than one section depending on what you mean.
For instance, compare
man crontab with
man 5 crontab -- chances are the latter is the one you meant to look up.
Often, a man page is referenced via suffixing it with the section enclosed in parentheses, e.g.:
This style has two main advantages:
Man pages are organized in sections, e.g. Section 1 includes all user command man pages, Section 2 all man pages for the system calls, Section 3 is for library functions etc.
On the command line, if you don't explicitly specify the section you get the first matching man page, in the default section traversal order, e.g.:
$ man read
BASH_BUILTINS(1) on Fedora. Where
$ man 2 read
displays the man page for the
read() system call.
Note that the positional specification of the section is not portable - e.g. on Solaris you would specify it like this:
$ man -s 2 read
man man also lists some of the available sections. But not necessarily all. For listing all available sections one may list the subdirectories of all directories listed in the default man path or the environment variable
$MANPATH. For example on a Fedora 23 system with some development packages installed
/usr/share/man has following subdirectories:
cs es id man0p man2 man3x man5x man7x man9x pt_BR sk zh_CN da fr it man1 man2x man4 man6 man8 mann pt_PT sv zh_TW de hr ja man1p man3 man4x man6x man8x pl ro tr en hu ko man1x man3p man5 man7 man9 pt ru zh
The directories with the
man prefix represent each section - while the other ones contain translated sections. Thus, to get a list of non-empty sections one could issue a command like this:
$ find /usr/share/man -type f | sed 's@^.*/man\(..*\)/.*$@\1@' \ | sort -u | column 0p 1p 3 4 6 8 1 2 3p 5 7
(the sections ending with
p are POSIX man pages)
To view a man page in another language (if available) one can set a language related environment variable, e.g.:
$ LC_MESSAGES=de_DE man read
Also, each section should have an introduction man page named
intro, e.g. viewable via:
$ man 2 intro
The definitions for SVr4 are:
1 User Commands 2 System Calls 3 library Functions 4 File Formats 5 Standards, Environment and Macros (e.g. man(5)) 6 Games and Demos 7 Device and Network Interfaces, Special Files 8 Maintenance Procedures 9 Kernel and Driver entry points and structures
These is the actual numbering for a "genetic" UNIX. POSIX does not define numbers.