What do the parentheses and number after a Unix command or C function mean?

228

72

I keep seeing parentheses and a number after a command in Unix or Linux or C function.

For example: man(8), ftok(2), mount(8), etc.

What do these mean? I see them in man too.

Malfist

Posted 2011-06-15T19:17:28.587

Reputation: 2 761

27

Cross-duplicate, on Unix and Linux: What do the numbers in a man page mean?.

– Peter Mortensen – 2011-06-16T03:30:12.630

Answers

225

Manpage sections.

  1. Common UNIX command that can be used by all users. e.g. ls(1)
  2. Unix and C system calls e.g. mmap(2)
  3. C library routines for C programs e.g. system(3)
  4. Special files e.g. sudoers(4)
  5. System file formats e.g. lmhosts(5)
  6. Games e.g. fortune(6)
  7. Miscellaneous e.g. regex(7)
  8. System administration commands that is run by root only e.g. iwconfig(8)
  9. (?Linux specific) e.g.ksoftirqd(9)

The reason behind sections is that there are things sharing manual pages - mkdir(1) is the command used to create a directory whereas mkdir(2) is a system call that can be used to create a directory in a C program. Thus the different sections.

Annotated References [1,2] (as suggested):
http://www.gsp.com/support/man/ - The FreeBSD manpages arranged according to sections
http://manpages.unixforum.co.uk/man-pages/linux/suse-linux-10.1/ - SUSE manpages arranged according to sections
http://www.december.com/unix/ref/mansec.html - Yet another table for manpage sections. Initial basis of the list (See older edits of this post for details)

[1] explanations and examples are spontaneous fabrications in my head, for the matter.
[2] not that it is academically sound, but request for reference is one of the thing that slowed the growth of wikipedia. skeptics are trying to get others reference everything and some of the contributors just get way too annoyed to further answer anything, not that those who try to add useless/baseless stuff are properly removed from the pool (they just get the reference-request tag tagged onto their additions, contents not removed...)

bubu

Posted 2011-06-15T19:17:28.587

Reputation: 9 283

OTOH, the skeptics made your answer more valuable than the "competing" https://stackoverflow.com/a/62972/4145951, so I'm upvoting it. ;)

– Nemo – 2015-01-19T07:54:59.450

@bubu, What's the diff between section 7 and section 1? – Pacerier – 2017-11-02T18:48:21.213

5Games (6) got a section of their own! – Jaywalker – 2011-06-16T08:22:30.870

5actually, it is more like funny program than games. caesar(6) and fortune(6) are at most funny.... and if you think bcd(6) is a game... okay, i'd place the unix guru badge on you – bubu – 2011-06-16T08:24:41.437

25To display the information, use the command: man <number> <command> example: man 1 mkdir and man 2 mkdir – Donny Kurnia – 2011-06-17T04:19:44.743

@DonnyKurnia the single most important fact one needs to know - you can figure out the rest yourself from here on, actually – n611x007 – 2012-06-23T05:41:53.670

85

An excerpt from man man:

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]

ssapkota

Posted 2011-06-15T19:17:28.587

Reputation: 1 213

2

This is not applicable on macOS.

– Franklin Yu – 2017-04-29T02:39:07.773

4"Unix is easy: type man man and the rest comes by itself" – gerrit – 2012-07-19T08:21:30.617

37

The number refers to the man page section the command or C function is in.

So you could access the man page of mount(8) by doing the command:

man 8 mount

Or of ftok(2) like such:

man 2 ftok

Wuffers

Posted 2011-06-15T19:17:28.587

Reputation: 16 645

2Out of curiosity, why isn't it man mount(8) or man ftok(2)? – JAB – 2011-06-15T20:13:57.057

7@JAB: Because most shells will take the parentheses specially. You can't use parentheses in any shell commands (without wanting to do something special). – Wuffers – 2011-06-15T20:16:24.330

Well that's interesting. – JAB – 2011-06-15T20:25:17.123

+1 This is the most essential thing you need to know - you can actually figure out the rest yourself (even without realizing man man). – n611x007 – 2012-06-23T05:43:37.737

12

They are section numbers of the traditional Unix manual pages. Your question has already been answered on Unix and Linux Stack Exchange a year ago, What do the numbers in a man page mean?.

JdeBP

Posted 2011-06-15T19:17:28.587

Reputation: 23 855

3

These are section numbers. If you want to read section 2 of mount then run:

man 2 mount

Some man pages have multiple sections.

jftuga

Posted 2011-06-15T19:17:28.587

Reputation: 2 877

3

These are the man section numbers.

Sections and Examples for linux man pages:

  • 1 - Programs or shell commands - cp, rm, dd and ps.
  • 2 - System calls - fork, exec, ioctl and poll.
  • 3 - Library calls - printf, malloc, pthread_* calls, cos, sin, tan etc.
  • 4 - devices e.g. null (/dev/null), port, random, lp.
  • 5 - File formats - users, groups, hosts, host.equiv.
  • 6 - games.
  • 7 - Miscellaneous (often overviews) - glob, intro, tcp, uri, url, locale.
  • 8 - Sys Admin commands and daemons - arp, mount, route, useradd, userdel etc.

Note there are differences between the man section list for linux and that for Unix System V variants (e.g. Solaris, BSD, SCO, Venix). More details from man page wiki.

Interestingly Ken Thompson and Denis Ritchie the famed Unix and C creators wrote the first man pages - at the insistence of their manager. Does that sound familiar?

To select a specific section number for a man entry on linux (printf has entries in sections 1 and 3).

man 3 printf

To view all man entries for cfdisk (use q at END of one page to get to the next page:

man -a cfdisk

To list all entries for a certain command use apropos

apropos cfdisk

suspectus

Posted 2011-06-15T19:17:28.587

Reputation: 3 957

2

It's the manual section number. Way back in the mists of time, this referred to the physical binder which contained that particular manual page.

From the man manpage on a modern Linux system:

   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]

Flup

Posted 2011-06-15T19:17:28.587

Reputation: 3 151

0

Manpage sections including non-standard ones on Arch Linux:

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

(thanks to @greg0ire for the idea of using konqueror)

Babken Vardanyan

Posted 2011-06-15T19:17:28.587

Reputation: 1 115