57

In Linux, how do I get the man pages for C functions rather than shell commands?

For example, when I type man bind, I get the manual page for the shell command bind and not the man page for socket binding C function.

2

2 Answers 2

65

Use:

man 2 bind

You need a result from a different section of the manual! Man searches various sections for the information you want. As devnull lists, the number indicates which section to search.

Incidentally, bind is a system call, not a C library function. System calls (kernel calls) are in section 2 of the manual, and library functions are in section 3.

man man will tell you how to use the man command!

Sign up to request clarification or add additional context in comments.

3 Comments

It might be worth clarifying that system calls are in the (2) section, and library functions in the (3) section. I.e. man 3 printf for printf().
I've been using Unix for over ten years and wasn't aware of this (always fell back to Internet searches). I would type something like man sleep\(3\) and give up! I think users would be more likely to reach their desired destination if the man pages read "SEE ALSO man 3 sleep".
There is also a 'bind' in section 3.
49

Saying man man would tell you:

SYNOPSIS man ... [[section] page ...] ...

   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
       conventions), e.g. man(7), groff(7)
   8   System administration commands (usually only for root)
   9   Kernel routines [Non standard]

For example, man 1 printf would show the manual for the printf shell utility, while man 3 printf would show the manual for printf() in libc.

(When in doubt, say man -k foobar. It will provide a list of man pages with foobar as the regex.)

4 Comments

I've been using man for a bit now, but somehow never tried to do man man.... Thanks!
Interesting. For me, man 3 printf returns No manual entry for printf in section 3
After installing 'man-pages', 'man 3 printf' shows correct info.
man -a is a convenient to get to the page you want, but man -s 3,2,3p is probably best when you know you want C. 3 must be before 2 for things like exit which are different, but 3p must be explicitly after 2 to avoid picking up posix, perl, etc. if you have their man pages installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.