Search code examples
linuxmanpage

Why do some Linux system calls have two man pages?


Example:

http://linux.die.net/man/2/socket
http://linux.die.net/man/7/socket

In what way they are different?


Solution

  • socket(2) provides documentation for the socket() system call; socket(7) describes how to use sockets (in general) on Linux.

    man man gives you an overview of sections:

       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]
    

    This list is more or less (though not quite) "universal" across UNIX systems, and the sections you're interested in most of the time. Wikipedia has more documentation on man sections as used in various UNIX systems.

    There are many "duplicate" manpages, for example crontab(1) describes /sbin/crontab, and crontab(5) describes the crontab file format.

    You can configure which section man uses if you don't explicitly add a section with the MANSECT environment variable; this defaults to 1 n l 8 3 0 2 5 4 9 6 7 on Linux.

    For an introduction to each section, look at man <n> intro (ie. man 7 intro).

    Bonus tip:
    apropos is your friend:

    $ apropos crontab
    anacrontab (5)       - configuration file for Anacron
    crontab (1)          - maintains crontab files for individual users
    crontab (1p)         - schedule periodic background work
    crontab (5)          - files used to schedule the execution of programs