11

Possible Duplicate:
Why do programs in Unix-like environments have numbers after their name?

I have seen several programs, such as GREP(3) and PING(8), listed in manpages. What is the significance of the digit in ()s?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
  • FWIW, to whoever voted to close this, anything related to man pages is definitely programming related. How can anybody program in unix without man pages? – Nathan Fellman May 20 '09 at 04:18

3 Answers3

14

If you run man man you will see the following information in the man page:

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]

Some names are associated with multiple entries, eg on my system 'sleep' has an entry in section 1 and an entry in section 3. You can specify the one you want with e.g.

man 3 sleep

Sometimes I just guess with

man -a sleep

which displays each entry associated with sleep in turn. I just go through them until I find the one I want. You can also try

man -k sleep

to get a slightly bigger listing of pages involving the term 'sleep'

leif
  • 3,003
  • 1
  • 19
  • 9
  • +1 I would mention that grep is (1), not (3), but you've got an explanation of what's usually where, so that's probably close enough. – Chris Lutz May 20 '09 at 04:12
  • It's possible that a system could have a grep(3) installed. You are right that the command line grep that we know and love is grep(1). – leif May 20 '09 at 04:15
5

The number indicates which section the manpage is in. For your examples:

grep(3)

To get the documentation, type

man 3 grep

More commonly, if there is no grep(2) or grep(1), you can get away with

man grep

However, I should note that grep is in section 1. Section 3 is generally reserved for C functions. An example is getopt: getopt(1) refers to the command-line utility getopt, but getopt(3) refers to the C function getopt. Likewise, read(1) is a program that reads from standard input, but read(2) is a POSIX system call for use in programs - it is one of the lowest-level forms of input you can get on most Linux (and other Unix) systems.

Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
Chris Lutz
  • 73,191
  • 16
  • 130
  • 183
  • Not all versions of "man" support an unadorned section name. Solaris in particular would think you're asking about a command named 3. Use the "-s" option to remove doubt. It also has sections that aren't just numbers, including 3c and 3socket. – Rob Kennedy May 20 '09 at 04:21
1

It's to tell you what man page section help is in... 8 is typically the location of Administrative related utilities (/sbin, /usr/sbin, etc.)

So help for GREP(3) is in man page section 3, and you could type man 3 grep to get the help for grep(3) directly.

John Weldon
  • 39,849
  • 11
  • 94
  • 127