Search code examples
shellmanpage

Reaching correct man page


When I type 'man read' on shell prompt it displays read shell command, how do I open documentation for read() C function. My question is not just for read applies to similar other functions like sleep()

I usually run to https://linux.die.net when it happens and refer documentation there, I am sure there would be way to get to right man page from shell prompt itself


Solution

  • man <section #> <page>
    

    From the man man 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]
    

    To look up what sections exist for a given page, you can use the -k flag:

    $ man -k ^sleep$
    sleep (1)            - delay for a specified amount of time
    sleep (3)            - sleep for a specified number of seconds