سؤال
There are certain C functions whose names are ambiguous with the Ubuntu commands eg: getopt. How do I view the man page of these functions? No doubt it is easily available on the internet but I am keen to not leave the terminal as far as possible.
المحلول
Use the format man [section] name
(e.g. man 3 getopt
) where section can be one of the followings:
1 User Commands
2 System Calls
3 C Library Functions
4 Devices and Special Files
5 File Formats and Conventions
6 Games et. Al.
7 Miscellanea
8 System Administration tools and Deamons
Consult man man
for more information.
نصائح أخرى
man 3 getopt
shows the manpages for C getopt.
see man man
man 3 getopt
gives c function information.
where as man 1 getopt
or man getopt
gives command information.
Pages are traditionally referred to using the notation "name(section)
": for example, ftp(1)
. The same page name may appear in more than one section of the manual, as when the names of system calls, user commands, or macro packages coincide.
man -wa getopt
gives you the list of manual pages for getopt
: in my system, it is:
/usr/share/man/man1/getopt.1.bz2
/usr/share/man/man3/getopt.3.bz2
/usr/share/man/man3p/getopt.3p.bz2
Or, alternatively, man -f getopt
:
getopt (1) - parse command options (enhanced)
getopt (3) - Parse command-line options
getopt [] (1) - parse command options (enhanced)
getopt [] (3) - Parse command-line options
getopt [] (3p) - command option parsing
You can then select the right manual page by using the number that is in the filename (in the first output) or in between parenthesis (in the second output): for example, man 1 getopt
or man 3 getopt
.
$ man 3 getopt
where 3
is section.
$ man man
As Sections. states:
The manual is generally split into eight numbered sections, organized as follows (on BSD, Unix and Linux):
Section Description
1. General commands
2. System calls
3. Library functions, covering in particular the C standard library
4. Special files (usually devices, those found in /dev) and drivers
5. File formats and conventions
6. Games and screensavers
7. Miscellanea
8. System administration commands and daemons
Unix System V uses a similar numbering scheme, except in a different order:
Section Description
1. General commands
1M. System administration commands and daemons
2. System calls
3. C library functions
4. File formats and conventions
5. Miscellanea
6. Games and screensavers
7. Special files (usually devices, those found in /dev) and drivers