Manual Pages and Info Files

Manual Pages and Info Files

Introduction

The most comprehensive documentation on MidnightBSD is in the form of manual pages. Nearly every program on the system comes with a short reference manual explaining the basic operation and available arguments. Manual pages are always available offline and are considered the authoritative reference for the commands, system calls, file formats, and devices that ship with the operating system.

Manual pages are intentionally terse. They document what a command does and what options it accepts, but they are not tutorials. For step-by-step guides and conceptual explanations, consult the documentation on this website or the FreeBSD Handbook, whose coverage of base system topics applies equally to MidnightBSD.

MidnightBSD manual pages are also available online at man.midnightbsd.org. This is useful for looking up documentation from another machine or when the system is not available.

Reading Manual Pages

Manual pages are viewed with the man command:

man command

For example, to read the manual page for ls:

man ls

To read the manual page for man itself:

man man

Manual pages open in a pager (usually less or more) so you can scroll through them. Press q to quit. See the Pager Navigation section for a full list of navigation keys.

References to manual pages in written documentation use parenthetical section numbers, such as ls(1) or chmod(2). The number indicates which section of the manual contains that entry. This notation is a hint that you can look up the topic with man.

Manual Page Sections

Manual pages are divided into numbered sections representing the type of topic. In MidnightBSD the following sections are available:

A quick way to remember: sections 1 and 8 cover commands (user and admin respectively), sections 2 and 3 cover programming interfaces, section 4 covers drivers, and section 5 covers configuration file formats.

Specifying a Section

In some cases, the same topic name appears in more than one section. For example, chmod is both a user command (section 1) and a C library system call (section 2). Running man chmod without a section number displays the first match found, which may not be the one you want.

To display the manual page from a specific section, provide the section number before the topic name:

man 1 chmod man 2 chmod

Other examples where specifying the section matters:

man 5 passwd man 4 ada man 8 mount man 3 printf

To see all available sections for a given name, use the -a flag. Each matching manual page is displayed in turn; press q to advance to the next one:

man -a chmod

Searching Manual Pages

If you do not know the exact name of a command or function, use man -k to search the short description of every manual page for a keyword:

man -k mail

This displays a list of manual page entries whose descriptions contain the word "mail". The output format is name(section) — description. This is equivalent to the apropos command:

apropos mail

To search for an exact command name match rather than a keyword, use whatis. It shows only entries whose name exactly matches the argument:

whatis chmod

To read the short descriptions for all commands in a directory:

cd /usr/sbin whatis * | more

The apropos and whatis databases are built from the manual pages installed on the system. If they return no results after installing new software, rebuild the database as root:

makewhatis

Manual Page Layout

Most manual pages follow a standard structure. Knowing these sections makes it faster to find the information you need:

When reading an unfamiliar manual page, start with NAME for a quick summary, then SYNOPSIS to understand the argument structure, then DESCRIPTION for the details. Check SEE ALSO to find related pages that may be more relevant to your task.

Pager Navigation

Manual pages are displayed through a pager. The default pager is set by the PAGER environment variable; less is the most common choice. See the Shells documentation for how to set PAGER.

Key bindings when reading a manual page in less:

To open a manual page at the first occurrence of a search term directly:

man -P "less -p pattern" command

To display a manual page formatted as plain text (useful for saving or piping):

man -P cat ls

MANPATH and Additional Pages

The man command searches a list of directories defined by the MANPATH environment variable. The default path includes /usr/share/man for the base system and /usr/local/share/man for software installed via mports.

If you install software to a non-standard location, add its manual directory to MANPATH in your shell startup file:

export MANPATH="/usr/share/man:/usr/local/share/man:/opt/myapp/man"

In tcsh:

setenv MANPATH "/usr/share/man:/usr/local/share/man:/opt/myapp/man"

To see the directories man is currently searching:

man --path

Manual pages for mports software are installed automatically when you install a package. They are placed in /usr/local/share/man, which is included in the default search path.

To display the manual page for a program installed in /usr/local without setting MANPATH:

man -M /usr/local/share/man command

GNU Info Files

MidnightBSD includes several applications and utilities produced by the Free Software Foundation (FSF). In addition to manual pages, these programs may include hypertext documents called info files. Info files use a node-and-link structure similar to a web page, allowing you to navigate between topics.

Info files are typically more detailed than manual pages for GNU software such as gcc, make, and the GNU C library. If a manual page's SEE ALSO section references an info file, the info file is likely the more complete reference.

To open the info reader at the top-level directory of all installed info files:

info

To open the info documentation for a specific program:

info make info gcc

Navigation inside the info reader:

If emacs is installed from mports, you can browse info files in its built-in info mode, which provides a more comfortable reading experience with mouse support. Launch it with:

emacs -f info

Or from within emacs, press C-h i (Ctrl+h then i).