man 3 ls will only show you a man page for ls in section 3 of the manual. Section 3 covers library functions; since there's (probably) no library function named ls, it won't find anything.
The man command without a section number searches the sections in a predefined order. On my Ubuntu 24.04 system, the default is "1 n l 8 3 0 2 3type 3posix 3pm 3perl 3am 5 4 9 6 7". The order can be reconfigured.
. So man ls will find the ls man page in section 1, which covers user commands.
The sections (on my Ubuntu system) are:
- Executable programs or shell commands
- System calls (functions provided by the kernel)
- Library calls (functions within program libraries)
- Special files (usually found in
/dev)
- File formats and conventions eg
/etc/passwd
- Games
- Miscellaneous (including macro packages and conventions), e.g.
man(7), groff(7)
- System administration commands (usually only for root)
- Kernel routines [Non standard]
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 the printf user command in section 1; to see the man page for the printf function, use man 3 printf. You'll often see these man pages referred to as printf(1) and printf(3), respectively.
There are several ways to specify a section number (some of these might not be available on all systems):
man 3 printf
man -s 3 printf
man 'printf(3)'
Stealing Borrowing 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 and chmod are good examples of this.