Section 16.1. Objective 1: Use and Manage Local System Documentation


16.1. Objective 1: Use and Manage Local System Documentation

Each Linux system is configured by default with extensive documentation from developers, authors, and Linux community members. With these documentation projects combined, your Linux distribution offers a comprehensive body of knowledge to enhance your skills as a sysadmin.

16.1.1. Text Files and Paging

At a fundamental level, documents stored electronically may be encoded in a variety of formats. For example, most word processors use proprietary file formats to store characters, text formatting, and printing control languages. While these relatively modern applications can be found on your Linux system, most of the documents and configuration files for both the operating system and system tools are in plain text.

In the context of Linux systems, plain text means files or streams of both printable characters and control characters. Each is represented using a standard encoding scheme, such as the American Standard Code for Information Interchange (ASCII) or one of its relatives. Text files are most conveniently viewed using a paging program.

16.1.1.1. Paging programs

A paging program displays contents of a text file one "page" at a time. Paging programs have the advantage of speed and simplicity over text editors (such as vi) because only pieces of the text files are loaded into a buffer at a time, instead of the entire file. In addition, since paging programs cannot edit file contents directly, unless you tell them to invoke an editor, there isn't a chance of accidentally changing a file.

The two paging applications commonly used on Linux are more and less. The more tool is named because it gives you "one more screen." Humorously, the less command is so known because "less is more."

more is the older of the two Unix paging systems and has limited capabilities, though more has been beefed up on Linux systems compared to their original Unix versions. The standard Unix more simply presents you with the text document one screen at a time, progressing forward through the screens with the spacebar. This functionality is shadowed by less's ability to move both forward and backward through a file, either line by line or a full screen at a time utilizing cursor keys and page up and page down keys, as well as standard vi movement keystrokes such as j, k, G, and so on. While both more and less on Linux have the ability for multidirectional movement and advanced searching capability, less has more movement options and supports more keyboard functions.

As a sysadmin, you will have the most exposure to these programs while reviewing manpages and system documentation.

16.1.2. Manpages

Traditional computer manuals covered everything from physical maintenance to programming libraries. While the books were convenient, many users didn't always want to dig through printed documentation or carry it around. So, as space became available, the man (manual) command was created to put the books on the system, allowing users immediate access to the information they needed in a searchable, quick-reference format.

There is a manpage for most commands on your system. There are also manpages for important files, library functions, shells, languages, devices, and other features. man is to your system what a dictionary is to your written language. That is, nearly everything is defined in detail, but you probably need to know in advance just what you're looking for.


Syntax

 man [options] [section] name 


Description

Format and display system manual pages from section on the topic of name. If section is omitted, the first manpage found is displayed.


Frequently used options


-a

Normally, man exits after displaying a single manpage. The -a option instructs man to display all manpages that match name, in a sequential fashion.


-d

Display debugging information.


-w

Print the locations of manpages instead of displaying them.


Example 1

View a manpage for mkfifo:

 $ man mkfifo ... 

Results for the first manpage found are scrolled on the screen.


Example 2

Determine what manpages are available for mkfifo:

 $ man -wa mkfifo /usr/share/man/man1/mkfifo.1 /usr/share/man/man3/mkfifo.3 

This shows that two manpages are available, one in section 1 (mkfifo.1) of the manual and another in section 3 (mkfifo.3). See the next section for a description of manpage sections .


Example 3

Display the mkfifo manpage from manual section 3:

 $ man 3 mkfifo 

16.1.2.1. Manual sections

Manpages are grouped into sections, and there are times when you should know the appropriate section in which to search for an item. For example, if you were interested in the mkfifo C-language function rather than the command, you must tell the man program to search the section on library functions (in this case, section 3, Linux Programmer's Manual):

 $ man 3 mkfifo 

An alternative would be to have the man program search all manual sections :

 $ man -a mkfifo 

The first example returns the mkfifo(3) manpage regarding the library function. The second returns pages for both the command and the function. In this case, the pages are delivered separately; terminating the pager on the first manpage with Ctrl-C causes the second to be displayed.

Manual sections are detailed in Table 16-1.

Table 16-1. Man sections

Section

Description

1

User programs

2

System calls

3

Library calls

4

Special files (usually found in /dev)

5

File formats

6

Games

7

Miscellaneous

8

System administration



Tip: Some systems might also have sections 9, n, and others, but only sections 1 through 8 are defined by the FHS.

The order in which man searches the sections for manpages is controlled by the MANSECT environment variable. MANSECT contains a colon-separated list of section numbers. If it is not set, man (as of Version 1.5k) behaves as if it were set to 1:8:2:3:4:5:6:7:9:tcl:n:l:p:o.

16.1.2.2. Manpage format

Most manpages are presented in a concise format with information grouped under well-known standard headings such as those shown in Table 16-2. Other manpage headings depend on the context of the individual manpage.

Table 16-2. Standard manpage headings

Heading

Description

Name

The name of the item, along with a description

Synopsis

A complete description of syntax or usage

Description

A brief description of the item

Options

Detailed information on each command-line option (for commands)

Return values

Information on function return values (for programming references)

See also

A list of related items that may be helpful

Bugs

Descriptions of unusual program behavior or known defects

Files

A list of important files related to the item, such as configuration files

Copying or copyright

A description of how the item is to be distributed or protected

Authors

A list of those who are responsible for the item


16.1.2.3. man mechanics

System manpages are stored in /usr/share/man and elsewhere. At any time, the manual pages available to the man command are contained within directories configured in your man configuration file, /etc/man.config. This file contains directives to the man, telling it where to search for pages (the MANPATH directive), the paging program to use (PAGER), and many others. This file essentially controls how man works on your system. To observe this, use the debug (-d) option to man to watch as it constructs a manpath (a directory search list) and prepares to display your selection:

 $ man -d mkfifo 

16.1.3. Information in /usr/share/doc

Manpages are particularly useful when you know what you're looking for, or at least have some good leads on how to find it. However, they are not tutorial in nature, nor do they often describe overall concepts. Fortunately, individuals in the Linux world not only contribute their programming skills, but many also generate excellent tutorial documents to assist others with features, procedures, or common problems. Many of these documents end up as HOWTO guides, FAQs (lists of Frequently Asked Questions), README files, or even exhaustive user manuals. These documents are often part of the source distribution of a particular program and, while valuable, don't fit elsewhere on the Linux system and are deposited in /usr/share/doc. Most of these files are ASCII text, which can be viewed with a pager, such as less, or with your favorite text editor. Some documents may be written in HTML for use with your web browser. Some text files may also be compressed with the gzip program and thus have the .gz extension.


Tip: /usr/share/doc is not required by the FHS, so its contents and layout are distribution-specific.

16.1.4. Info Pages

The Free Software Foundation (http://www.fsf.org) has moved much of the documentation for the GNU project to a documentation format called info. Info pages are part of a system called Texinfo, which uses a single source file to display information on screen and on paper. Texinfo is hypertext and creates a browserlike interface on a terminal or terminal window (Emacs users will recognize the menu system as the editor's online help). For GNU software, Texinfo is the definitive documentation mechanism. Texinfo can be viewed by running the info command. For example, the texinfo document on mkfifo can be displayed using the following command:

 $ info mkfifo 

The result will be a display similar to the example in Figure 16-1.

Figure 16-1. Info display in a terminal window


Basic navigation commands for the info system are listed in Table 16-3.

Table 16-3. Info commands

Command

Description

Tab

Move among hypertext links.

Enter

Follow hypertext links.

d

Return to the top (directory node) of the menu.

?

List all info commands.

p and n

Move to previous and next pages, respectively.

u

Move up one level in the texinfo hierarchy.

q

Terminate the system.

h

Show a primer for first-time users.

/string

Enter a string.

/pattern

Search forward for pattern, which can be a regular expression.



Tip: Many Linux distributions also include the info viewer pinfo, which works much like the text-based web browser lynx.

Manpages and other types of system documentation are packaged and installed by default with most Linux distributions. For example, this means that both the manpage and executable program for wc are contained in the coreutils (or textutils on older distributions) package. Other documentation, such as Linux Documentation Project (LDP) guides and HOWTOs, may be contained in standalone packages, depending on the distribution.



LPI Linux Certification in a Nutshell
LPI Linux Certification in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596005288
EAN: 2147483647
Year: 2004
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net