Thread: Questions about using man pages on a linux system.

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    84

    Questions about using man pages on a linux system.

    Hi,

    I have been programming in C on a linux computer for almost 2 years (exclusively). I love that I can get the man page for almost any command used in C. But I have questions that don't make sense to me...

    When I use a man page, I first use:
    Code:
    man 3 C_PROGRAMMING_COMMAND
    Usually works. But then I need to find the man page for read, but this doesn't work:
    Code:
    $ man 3 read
    No manual entry for read in section 3
    So I am forced to try the command again with success:
    Code:
    man 2 read
    Using man 2 and man 3 produce pages with the same header:
    Code:
    Linux Programmer's Manual
    Now the questions...

    1) Why aren't they under the same man "number" (ie. all commands are at least listed under 3) if they are part of the Linux Programmer's Manual?

    2) Is there an obvious way to determine which man "number" each command would be found under? Is it just older commands that are under man 2?

    3) Is there a way to force all man pages listed under man 2 to also be included in man 3 (so I don't have to redo a command with a different number)?

    Ty,
    Yonut

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,154
    Normally, there's no need to bother with the section number.
    man read
    man strcat

    These automatically locate the correct section for you.

    The only time you need the section number is when the same thing appears in more than one section, like printf.

    The apropos command is useful in this respect.
    Quote Originally Posted by apropos
    $ apropos printf
    asprintf (3) - print to allocated string
    dprintf (3) - formatted output conversion
    fprintf (3) - formatted output conversion
    fwprintf (3) - formatted wide-character output conversion
    printf (1) - format and print data
    printf (3) - formatted output conversion
    It's a grep-like tool for searching manual page descriptions.

    As for the sections themselves,
    Quote Originally Posted by man man
    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, e.g. /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]
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2019
    Posts
    84
    I do remember using just man but I believe it didn't give the right one for printf.

    I feel I have found a way around my problem. I'm using the following in my .aliases file (p for programing man pages):
    Code:
    pan() {
        man 3 $1 || man 2 $1 || man $1
    }
    I added the final || for man just in case I get to used to using pan.

    Thanks Salem, apropos should help me in the future.

  4. #4
    Registered User
    Join Date
    Apr 2019
    Posts
    84
    Ok, I made my function a little better. I originally used pan becuase when I tried to use man the command became recursive.

    I fixed it by putting the full path to the man program. Now I can use man normally.

    Code:
    man() {
        /usr/bin/man 3 $1 || /usr/bin/man 2 $1 || /usr/bin/man $1
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. System ping Linux questions
    By knik653 in forum C++ Programming
    Replies: 3
    Last Post: 03-22-2022, 12:44 PM
  2. System ping Linux questions
    By knik653 in forum C Programming
    Replies: 1
    Last Post: 03-22-2022, 11:15 AM
  3. A few questions on system()
    By Jetlaw in forum C++ Programming
    Replies: 5
    Last Post: 03-30-2006, 10:38 AM
  4. creating a user login system for web pages
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 07-04-2002, 11:02 PM

Tags for this Thread