I'm wondering what's the difference between "man 3 command" vs "man command"?
I read in wiki (http://en.wikipedia.org/wiki/Man_page) that man 3 is used in Linux in section 3 of the man pages. And section 3 refers to Library functions, covering in particular the C standard library.
I tried "man 3 ls" and got this:
No entry for ls in section 3 of the manual
I wonder when to use man 3 and when to use man and do they serve difference purposes?
Thanks.
Best Answer
man 3 ls
will only show you a man page forls
in section 3 of the manual. Section 3 covers library functions; since there's (probably) no library function namedls
, it won't find anything.The
man
command without a section number searches the sections in a predefined order that I don't remember, but it's likely to be close to numerical order starting at 1. Soman ls
will find thels
man page in section 1, which covers user commands.The sections (on my Ubuntu system) are:
Specifying the section can be useful for things that exist with the same name in more than one section. For example,
man printf
will show you the man page for theprintf
user command in section 1; to see the man page for theprintf
function, useman 3 printf
. You'll often see these man pages referred to asprintf(1)
andprintf(3)
, respectively.StealingBorrowing from abernert's answer, it's common to see a user command (section 1) that's a wrapper for a system call (section 2) or library call (section 3) with the same name;chown
andchmod
are good examples of this.