Appendix A. Using Linux Manual Pages

Manual Page Sections

The online manual pages found in Linux provide a wealth of information. The manual pages are loosely grouped by category into the following sections:

  1. User commands and application programs.

  2. System calls. A complete list of system calls can be found at the end of this appendix.

  3. Library functions—these functions do not directly invoke kernel primitives.

  4. Devices.

  5. File formats.

  6. Games and demonstrations.

  7. Special conventions and protocols, character set standards, the standard file system layout, and a variety of other miscellaneous things.

  8. Administrative and privileged commands available only to the superuser.

  9. Device drivers and kernel interfaces.

  10. New.

There are a variety of ways to access manual page information. The most standard approach is to use the man utility on the command line. For example, almost every section has a manual page called intro that provides an overview of the section. To obtain the proper intro manual page for a section, the section number is passed on the command line when the man command is invoked. For example, the intro manual page for Section 2 (system calls) is specified as

linux$ man 2 intro

On the command line a manual page can be sent to the printer using the command sequence

linux$ man 2 intro | col -b | lp

In this sequence the output of the man command is piped to the col utility. This utility, when passed the -b option, filters out any backspaces and outputs only the last character written to each column position. The output of the col utility is then piped to lp for printing.

Another approach is to use the info utility. This program, which is a document-reading utility, helps to facilitate manual page navigation and access to related topics. The command line sequence

linux$ info info

brings up the manual page on the info utility. On our Linux system this brings up the following screen.

File: info.info, Node: Top, Next: Getting Started, Up: (dir)

Info: An Introduction
*********************

  Info is a program, which you are using now, for reading documentation of
computer programs. The GNU Project distributes most of its on-line manuals
in the Info format, so you need a program called "Info reader" to read the
manuals. One of such programs you are using now.

  If you are new to Info and want to learn how to use it, type the
command 'h' now. It brings you to a programmed instruction sequence.

  To learn advanced Info commands, type 'n' twice. This brings you to
'Info for Experts', skipping over the 'Getting Started' chapter.

* Menu:

* Getting Started::          Getting started using an Info reader.
* Advanced Info::            Advanced commands within Info.
* Creating an Info File::    How to make your own Info file.
* Index::                    An index of topics, commands, and variables.

Entering the letter h at this first screen displays the basics of how to use this utility. Entering the letter q quits (exit) the info utility.

Even another approach is to use xman, the X Window System manual browser. For example, on our Linux system entering the command sequence

linux$ setenv MANPATH /mit/kit/man:/usr/share/man
linux$ xhost+
linux$ xman &

assigns the environment variable MANPATH (used by xman) the directory locations to be searched,[1] disables access control (allowing X Window clients to connect from any host), and invokes xman, placing it in the background. On the client a small X Window similar to the one below is displayed.

Manual Page Sections

Selecting [Help] displays a window with online help, [Quit] terminates service, and [Manual Page] displays a window containing a manual page browser. Entering [Ctrl] + [S] after selecting [Manual Page] generates a text entry box where the name of a specific command can be entered.

The file /etc/man.config is a text based file that holds the default customization specifications for the man utility. Contained in this file are a variety of uppercase identifiers which are assigned values. These identifiers parallel corresponding environment variables used by the man utility. The values assigned to the identifiers in the man.config file act as the default values if the corresponding environment variable has not been set. Aside from MANPATH another item of passing interest is the value assigned to MANSECT. MANSECT stipulates which manual sections are to be searched and their order. On our system when initially configured MANSECT is set to:

MANSECT   1:8:2:3:4:5:6:7:9:tcl:n:l:p:o

This is fine from an administrative viewpoint. However, if you are doing a great deal of programming you might want to change the default order by moving section 8 (administrative and privileged commands) further back in the sequence and placing section 2 (system calls) and 3 (library functions) nearer the front. One such rearrangement would be:

MANSECT   3:2:1:4:5:6:7:8:9:tcl:n:l:p:o

Manual Page Format

Individual manual pages, as viewed with the man command, follow a somewhat standard format. A typical manual page (perror found in Section 3) is shown below.

PERROR(3)               Library functions                    PERROR(3)
NAME
   perror - print a system error message        <-- 1

SYNOPSIS
   #include <stdio.h>
   void perror(const char *s);       <-- 2

   #include <errno.h>
   const char *sys_errlist[];
   int sys_nerr;
DESCRIPTION
   The routine perror() produces a message on the standard error output, de-
   scribing the last error encountered during a call to a system or library
   function. First (if s is not NULL and *s is not NUL) the argument string
   s is printed, followed by a colon and a blank. Then the message and a new-
   line.       <-- 3
   .             |
   .             |
   .       <-- 3
   that errno is undefined after a successful library call: this call may well
   change this variable, even though it succeeds, for example because it in-
   ternally used some other library function that failed. Thus, if a failing
   call is not immediately followed by a call to perror, the value of errno
   should be saved.
CONFORMING TO
   ANSI C, BSD 4.3, POSIX, X/OPEN        <-- 4

SEE ALSO
   strerror(3)       <-- 5

                              <-- 6 2001-12-14                       PERROR(3)
  • (1)A brief summary-often is the same information returned by the apros or man -k command.

  • (2)Syntactical information—include files, external variables, function prototype, function return data type, parameter data types, and so on. This is a key section. Special attention should be paid to arguments passed as a reference.

  • (3)A detailed narration of what this system call or library function does.

  • (4)As provided, the standards this system call or library function meets.

  • (5)Other related system calls and/or library functions.

  • (6)Last update .

Across the top of the manual page is a title line. Following the title line is a series of subdivisions delineated by uppercase labels. The subdivisions common to most (but not all) system call sand library function manual pages are

NAME

The name of the item is followed by a brief description. The description is often similar to, if not the same as, the description returned when a man -k (know) query for a specific topic is made.[2] The man -k pipe command returns all manual page summaries for any item (system call, library function, etc.) that contains the term pipe. For example,

linux$  man   -k pipe
fifo     (4)  - first-in first-out special file,
Manual Page Format named pipe
funzip   (1)  - filter for extracting from a ZIP
Manual Page Format archive in
                a pipe
IO::Pipe (3pm)- supply object methods for pipes
mkfifo   (1)  - make FIFOs (named pipes)
mkfifo   (3)  - make a FIFO special file (a named
Manual Page Format pipe)
open     (n)  - Open a file-based or command
Manual Page Format pipeline channel
perlipc  (1)  - Perl interprocess communication 
Manual Page Format(signals,
                fifos, pipes, safe subprocesses,
Manual Page Format sockets,
                and semaphores)
pipe     (2)  - create pipe

On most systems, man -k is equivalent to using the apropos utility, (i.e., man -k pipe returns the information as apropos pipe).

SYNOPSIS

This provides the syntactical information for the correct use of the item. In the case of a system call or library function, the requisite include file(s), external variables referenced, and prototype are given. The data type of the return value of the system call or library function can be obtained from the prototype definition. For example, the manual page for the perror library function has the following SYNOPSIS:

#include <stdio.h>
void perror(const char *s);

#include <errno.h>
const char *sys_errlist[];
int sys_nerr;

This indicates that to use perror, the header file stdio.h must be included. The perror call accepts a single argument, s, which is a pointer to a constant of type char. The return value for perror is of type void, indicating it does not return a value. Additionally, the SYNOPSIS indicates that if we want to make use of the external list of errors referenced by sys_errlist or the external variable sys_nerr (that has the number of possible errors), we should include the file errno.h. Be sure to note arguments that are pointers (references). These arguments must reference the correct data type (e.g., char, int, etc.). If information is to be passed to the system call or library function, the referenced object must be set to the proper initial value. In addition, if information is to be returned via the reference, the programmer must allocate sufficient space for the referenced item prior to the call.

DESCRIPTION

This subdivision contains a detailed narration of what the system call or library function does.

RETURN VALUE

The value(s) the system call or library function returns and how to interpret them. The RETURN VALUE entry should indicate whether or not errno is set.

CONFORMING TO

The standard(s) to which the system call or library function conforms. Typically the standards are abbreviated, such as SVr4, SVID, POSIX, X/OPEN, or BSD 4.3. On occasion a specific option for compilation and/or the definition of a specific constant (such as _GNU_SOURCE) is noted.

ERRORS

When present (i.e., errno is set), this entry lists the error codes generated by the system call or library function if it fails. A short explanation of how to interpret each error code is given.

FILES

Files accessed or modified by the system call or library function.

SEE ALSO

Other items of interest, such as related system calls or library functions.

NOTES

A catchall containing additional pertinent information that does not fall into any particular category.

LINUX NOTES

Notes specific to the Linux implementation.

AUTHORS

A list of authors (often with their email address).

[2] The -k command option for man uses the windex database, which is created by running the catman program. If the system administrator has not run this program, or the windex database is out of date, the -k option for man will not work correctly.

There are several other manual page divisions that surface on an infrequent basis. These, like those above, are usually self-explanatory (e.g., OPTIONS, EXAMPLE, BUGS, HISTORY, WARNINGS, DIAGNOSTICS, etc.). On occasion, small flashes of self-deprecating humor are encountered. The following is from the manual page on the system command tune2fs (used for tuning a second extended file system in Linux) “We haven't found any bugs yet. That doesn't mean there aren't any....” Unfortunately, as things become more standardized, such frivolities are becoming less common.

Standard Linux System Calls

_llseek

init_module

sched_setaffinity

_newselect

ioctl

sched_setparam

_sysctl

ioperm

sched_setscheduler

access

iopl

sched_yield

acct

ipc

security

adjtimex

kill

select

afs_syscall

lchown

sendfile

alarm

lchown32

sendfile64

bdflush

lgetxattr

setdomainname

break

link

setfsgid

brk

listxattr

setfsgid32

capget

llistxattr

setfsuid

capset

lock

setfsuid32

chdir

lremovexattr

setgid

chmod

lseek

setgid32

chown

lsetxattr

setgroups

chown32

lstat

setgroups32

chroot

lstat64

sethostname

clone

madvise

setitimer

close

madvise1

setpgid

creat

mincore

setpriority

create_module

mkdir

setregid

delete_module

mknod

setregid32

dup

mlock

setresgid

dup2

mlockall

setresgid32

execve

mmap

setresuid

exit, _exit

mmap2

setresuid32

fchdir

modify_ldt

setreuid

fchmod

mount

setreuid32

fchown

mprotect

setrlimit

fchown32

mpx

setsid

fcntl

mremap

settimeofday

fcntl64

msync

setuid

fdatasync

munlock

setuid32

fgetxattr

munlockall

setxattr

flistxattr

munmap

sgetmask

flock

nanosleep

sigaction

fork

nfsservctl

sigaltstack

fremovexattr

nice

signal

fsetxattr

oldfstat

sigpending

fstat

oldlstat

sigprocmask

fstat64

oldolduname

sigreturn

fstatfs

oldstat

sigsuspend

fsync

olduname

socketcall

ftime

open

ssetmask

ftruncate

pause

stat

ftruncate64

personality

stat64

futex

pipe

statfs

get_kernel_syms

pivot_root

stime

getcwd

poll

stty

getdents

prctl

swapoff

getdents64

pread

swapon

getegid

prof

symlink

getegid32

profil

sync

geteuid

ptrace

sysfs

geteuid32

putpmsg

sysinfo

getgid

pwrite

syslog

getgid32

query_module

time

getgroups

quotactl

times

getgroups32

read

tkill

getitimer

readahead

truncate

getpgid

readdir

truncate64

getpgrp

readlink

ugetrlimit

getpid

readv

ulimit

getpmsg

reboot

umask

getppid

removexattr

umount

getpriority

rename

umount2

getresgid

rmdir

uname

getresgid32

rt_sigaction

unlink

getresuid

rt_sigpending

uselib

getresuid32

rt_sigprocmask

ustat

getrlimit

rt_sigqueueinfo

utime

getrusage

rt_sigreturn

vfork

getsid

rt_sigsuspend

vhangup

gettid

rt_sigtimedwait

vm86

gettimeofday

sched_get_priority_max

vm86old

getuid

sched_get_priority_min

wait4

getuid32

sched_getaffinity

waitpid

getxattr

sched_getparam

write

gtty

sched_getscheduler

writev

idle

sched_rr_get_interval

 


[1] Things get a bit dicey here as they vary somewhat from system to system. Check the file /etc/man.config for specifics about the content of the MANPATH variable. In any case, when using xman, be sure to add /mit/kit/man to the directories to be searched.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.121.81