UNIX systems tools are typically accompanied by a man page. These provide a brief description of the command, it's optional parameters and modes, and any other related information that may be of use to the user.
- Almost all Unix MAN pages use the section numbering: (1) NAME, (2) SYNOPSIS, (3) DESCRIPTION, (4) FILES - files the command might use to do work, (5) SEE ALSO, (6) NOTES, (7) AUTHOR, (8) BUGS, with extra and optional sections as needed.
- You normally have an initial line:
Foo /- Does foo things
with this dash that gives a short description. This allows the man-page to be added to the 'whatis' database used byman -k
andapropos
commands, if applicable. - Boldface is typically used to denote program and filenames
\fB
: Change font to boldface\fI
: Change font to italics\fR
: Change font to roman type\fP
: Set font to previous selection.TH FOO 1 "2023-02-24"
: Set the title of the page to "foo" with the date, and use section 1 for user-commands (section 2 is system calls, etc.).SH "Bar"
: Start a section called "Bar".TP
Creates a tag. The line following is the tag, and the one thereafter the tag description or text. Use this for options to the program.br
: Cause a break to force following text to appear on next line. Good for splitting long titles..ce
: Center the next line.sN
: Make the textN
point size. Return to default with.s0
.
\(*a
: 'a' for alpha symbol, 'b' for beta, 'c' for squiggly thing, 'p' for pi. etc\(em
: em dash\(bu
: bullet symbol\(dg
: dagger symbol
In general, troff/groff uses the backslash symbol to introduce a command, with the most common being f for font and s for point size.
Build as follows:
groff -Tascii -man <name>.man | more
The option -man
tells groff to build a manual page using the man macro, and -Tascii
to produce plain ASCII output. Other options might be:
-Tps
: Produce postscript which you can save to a file, and view or print.-Tdvi
will produce device-independent.dvi
output similar to Tex
Depends on your system, but you can just copy manual.man
(assuming that's your new manual file to install to:
- macOS: In
/usr/local/share
you can find different subdirectories depending on what kind of manual you're providing (man1,man2,man3,...). Place your document into that directory with the format:<name-of-utility>.N
whereN
is the manual number entry for your manual.
If you can't edit the manpage directory, update the MANPATH
variable in your profile to include a local man-page directory. In my case, I updated ~/.zshrc
with export MANPATH=$PATH:/Users/$USER/doc/man
.
.TH COFFEE 1 "24 Feb 2023"
.ce
\s14The coffee command line utility\s0
.SH NAME
coffee /- Control remote coffee machine
.SH SYNOPSIS
\fBcoffee\fP [ -h | -b ] [ -t \fItype\fP ]
\fIamount\fP
.SH DESCRIPTION
\fBcoffee\fP queues a request to the remote coffee machine at the device \fB/dev/cf0\fR.
The required \fIamount\fP arugment specifies the number of cups, generally between 0 and 12 on ISO standard coffee machines.
.SS Options
.TP
\fB-h\fP
Brew hot coffee. Cold is the default.
.TP
\fB-h\fP
Burn coffee. Especially useful when executing \fBcoffee\fP on behalf of your boss.
.TP
\fB-t \fItype\fR
Specify the type of coffee to brew, where \fItype\fP is one of \fBcolumbian\fP, \fBregular\fP, or \fBdecaf\fP.
.SH FILES
.TP
\fC/dev/cf0\fR
\(bu The remote coffee machine device
.SH "SEE ALSO"
milk(5), sugar(5)
.SH BUGS
May require human intervention if coffee supply is exhausted
.DS
expr: | number
| variable
| ( expr )
| expr binop expr
| unop expr
| function ( arguments )
.DE