.\" 2007-05-30 created by mtk, using text from old man.7 plus
.\" rewrites and additional text.
.\"
-.TH MAN-PAGES 7 2015-07-23 "Linux" "Linux Programmer's Manual"
+.TH MAN-PAGES 7 2020-04-11 "Linux" "Linux Programmer's Manual"
.SH NAME
man-pages \- conventions for writing Linux man pages
.SH SYNOPSIS
which documents the user-space API provided by the Linux kernel
and the GNU C library.
The project thus provides most of the pages in Section 2,
-as well as many of the pages that appear
-in Sections 3, 4, 5, and 7 of the man pages on a Linux system.
+many of the pages that appear in Sections 3, 4, and 7,
+and a few of the pages that appear in Sections 1, 5, and 8
+of the man pages on a Linux system.
The conventions described on this page may also be useful
for authors writing man pages for other projects.
.SS Sections of the manual pages
.PP
The manual Sections are traditionally defined as follows:
-.TP 10
+.TP
.B 1 User commands (Programs)
-Those commands that can be executed by the user from within
+Commands that can be executed by the user from within
a shell.
.TP
.B 2 System calls
-Those functions which wrap operations performed by the kernel.
+Functions which wrap operations performed by the kernel.
.TP
.B 3 Library calls
All library functions excluding the system call wrappers
wherever possible.
This helps avoid line-wrapping in some mail clients when patches are
submitted inline.
-
-New sentences should be started on new lines.
-This makes it easier to see the effect of patches,
-which often operate at the level of individual sentences.
.SS Title line
The first command in a man page should be a
.B TH
command:
+.PP
.RS
-.sp
.B \&.TH
.I "title section date source manual"
-.sp
.RE
+.PP
where:
.RS
.TP 10
The date of the last nontrivial change that was made to the man page.
(Within the
.I man-pages
-project, the necessary updates to these timetamps are handled
+project, the necessary updates to these timestamps are handled
automatically by scripts, so there is no need to manually update
them as part of a patch.)
Dates should be written in the form YYYY-MM-DD.
.TP
.I source
The source of the command, function, or system call.
-
+.IP
For those few \fIman-pages\fP pages in Sections 1 and 8,
probably you just want to write
.IR GNU .
-
+.IP
For system calls, just write
.IR "Linux" .
(An earlier practice was to write the version number
However, this was never done consistently, and so was
probably worse than including no version number.
Henceforth, avoid including a version number.)
-
+.IP
For library calls that are part of glibc or one of the
other common GNU libraries, just use
.IR "GNU C Library" ", " GNU ,
or an empty string.
-
+.IP
For Section 4 pages, use
.IR "Linux" .
-
+.IP
In cases of doubt, just write
.IR Linux ", or " GNU .
.TP
sections.
Arrange a new manual page so that sections
are placed in the order shown in the list.
-.in +0.5i
+.PP
+.in +4n
.nf
-
\fBNAME\fP
\fBSYNOPSIS\fP
CONFIGURATION [Normally only in Section 4]
BUGS
EXAMPLE
.\" AUTHORS sections are discouraged
-.\" AUTHORS [Discouraged]
+AUTHORS [Discouraged]
+REPORTING BUGS [Not used in man-pages]
+COPYRIGHT [Not used in man-pages]
\fBSEE ALSO\fP
-
.fi
.in
+.PP
.IR "Where a traditional heading would apply" ", " "please use it" ;
this kind of consistency can make the information easier to understand.
If you must, you can create your own
However, before doing this, consider whether you could use the
traditional headings, with some subsections (\fI.SS\fP) within
those sections.
-
+.PP
The following list elaborates on the contents of each of
the above sections.
-.TP 14
+.TP
.B NAME
The name of this manual page.
-
+.IP
See
.BR man (7)
for important details of the line(s) that should follow the
\fB.SH NAME\fP command.
All words in this line (including the word immediately
-following the "\\\-") should be in lowercase,
+following the "\e\-") should be in lowercase,
except where English or technical terminological convention
dictates otherwise.
.TP
.B SYNOPSIS
A brief summary of the command or function's interface.
-
+.IP
For commands, this shows the syntax of the command and its arguments
(including options);
boldface is used for as-is text and italics are used to
For functions, it shows any required data declarations or
.B #include
directives, followed by the function declaration.
-
+.IP
Where a feature test macro must be defined in order to obtain
the declaration of a function (or a variable) from a header file,
then the SYNOPSIS should indicate this, as described in
.TP
.B CONFIGURATION
Configuration details for a device.
-
+.IP
This section normally appears only in Section 4 pages.
.TP
.B DESCRIPTION
An explanation of what the program, function, or format does.
-
+.IP
Discuss how it interacts with files and standard input, and what it
produces on standard output or standard error.
Omit internals and implementation details unless they're critical for
.\" section (and just place an overview in the
.\" .B DESCRIPTION
.\" section).
-
+.IP
When describing new behavior or new flags for
a system call or library function,
be careful to note the kernel or C library version
.B OPTIONS
A description of the command-line options accepted by a
program and how they change its behavior.
-
+.IP
This section should appear only for Section 1 and 8 manual pages.
.\" .TP
.\" .B USAGE
.B EXIT STATUS
A list of the possible exit status values of a program and
the conditions that cause these values to be returned.
-
+.IP
This section should appear only for Section 1 and 8 manual pages.
.TP
.B RETURN VALUE
.I errno
in the event of an error, along with information about the cause
of the errors.
-
+.IP
+Where several different conditions produce the same error,
+the preferred approach is to create separate list entries
+(with duplicate error names) for each of the conditions.
+This makes the separate conditions clear, may make the list easier to read,
+and allows metainformation
+(e.g., kernel version number where the condition first became applicable)
+to be more easily marked for each condition.
+.IP
.IR "The error list should be in alphabetical order" .
.TP
.B ENVIRONMENT
A list of the files the program or function uses, such as
configuration files, startup files,
and files the program directly operates on.
-
+.IP
Give the full pathname of these files, and use the installation
process to modify the directory part to match user preferences.
For many programs, the default installation location is in
A brief summary of the Linux kernel or glibc versions where a
system call or library function appeared,
or changed significantly in its operation.
-
+.IP
As a general rule, every new interface should
include a VERSIONS section in its manual page.
Unfortunately,
(i.e., changes since kernel 2.2),
and library functions that have been added to glibc since version 2.1
(i.e., changes since glibc 2.0).
-
+.IP
The
.BR syscalls (2)
manual page also provides information about kernel versions
.B CONFORMING TO
A description of any standards or conventions that relate to the function
or command described by the manual page.
-
+.IP
The preferred terms to use for the various standards are listed as
headings in
.BR standards (7).
-
+.IP
For a page in Section 2 or 3,
this section should note the POSIX.1
version(s) that the call conforms to,
or the SVr4 and 4.xBSD implementation standards,
unless the call was specified in those standards,
but isn't in the current version of POSIX.1.)
-
+.IP
If the call is not governed by any standards but commonly
exists on other systems, note them.
If the call is Linux-specific, note this.
-
+.IP
If this section consists of just a list of standards
(which it commonly does),
terminate the list with a period (\(aq.\(aq).
.TP
.B NOTES
Miscellaneous notes.
-
+.IP
For Section 2 and 3 man pages you may find it useful to include
subsections (\fBSS\fP) named \fILinux Notes\fP and \fIGlibc Notes\fP.
-
+.IP
In Section 2, use the heading
.I "C library/kernel differences"
to mark off notes that describe the differences (if any) between
.B EXAMPLE
One or more examples demonstrating how this function, file or
command is used.
-
+.IP
For details on writing example programs,
-see \fIExample Programs\fP below.
+see \fIExample programs\fP below.
.TP
.B AUTHORS
A list of authors of the documentation or program.
-
+.IP
\fBUse of an AUTHORS section is strongly discouraged\fP.
Generally, it is better not to clutter every page with a list
of (over time potentially numerous) authors;
If you are the author of a device driver and want to include
an address for reporting bugs, place this under the BUGS section.
.TP
+.B REPORTING BUGS
+The
+.IR man-pages
+project doesn't use a REPORTING BUGS section in manual pages.
+Information on reporting bugs is instead supplied in the
+script-generated COLOPHON section.
+However, various projects do use a REPORTING BUGS section.
+it is recommended to place it near the foot of the page.
+.TP
+.B COPYRIGHT
+The
+.IR man-pages
+project doesn't use a COPYRIGHT section in manual pages.
+Copyright information is instead maintained in the page source.
+In pages where this section is present,
+it is recommended to place it near the foot of the page, just above SEE ALSO.
+.TP
.B SEE ALSO
A comma-separated list of related man pages, possibly followed by
other related pages or documents.
-
+.IP
The list should be ordered by section number and
-then alphabetically by name
+then alphabetically by name.
Do not terminate this list with a period.
.IP
Where the SEE ALSO list contains many long manual page names,
(don't hyphenate)
directives.
Hyphenation of individual page names can be prevented
-by preceding words with the string "\\%".
-
+by preceding words with the string "\e%".
+.IP
Given the distributed, autonomous nature of FOSS projects
and their documentation, it is sometimes necessary\(emand in many cases
desirable\(emthat the SEE ALSO section includes references to
pages.
Use of "they" ("them", "themself", "their") as a gender-neutral singular
pronoun is acceptable.
-.SS Font conventions
+.\"
+.SS Formatting conventions for manual pages describing commands
.PP
-For functions, the arguments are always specified using italics,
+For manual pages that describe a command (typically in Sections 1 and 8),
+the arguments are always specified using italics,
+.IR "even in the SYNOPSIS section" .
+.PP
+The name of the command, and its options, should
+always be formatted in bold.
+.\"
+.SS Formatting conventions for manual pages describing functions
+For manual pages that describe functions (typically in Sections 2 and 3),
+the arguments are always specified using italics,
.IR "even in the SYNOPSIS section" ,
where the rest of the function is specified in bold:
.PP
.PP
Variable names should, like argument names, be specified in italics.
.PP
+Any reference to the subject of the current manual page
+should be written with the name in bold followed by
+a pair of parentheses in Roman (normal) font.
+For example, in the
+.BR fcntl (2)
+man page, references to the subject of the page would be written as:
+.BR fcntl ().
+The preferred way to write this in the source file is:
+.PP
+.EX
+ .BR fcntl ()
+.EE
+.PP
+(Using this format, rather than the use of "\efB...\efP()"
+makes it easier to write tools that parse man page source files.)
+.\"
+.SS Use semantic newlines
+In the source of a manual page,
+new sentences should be started on new lines,
+and long sentences should split into lines at clause breaks
+(commas, semicolons, colons, and so on).
+This convention, sometimes known as "semantic newlines",
+makes it easier to see the effect of patches,
+which often operate at the level of individual sentences or sentence clauses.
+.\"
+.SS Formatting conventions (general)
+.PP
+Paragraphs should be separated by suitable markers (usually either
+.I .PP
+or
+.IR .IP ).
+Do
+.I not
+separate paragraphs using blank lines, as this results in poor rendering
+in some output formats (such as PostScript and PDF).
+.PP
Filenames (whether pathnames, or references to header files)
are always in italics (e.g.,
.IR <stdio.h> ),
Complete commands should, if long,
be written as an indented line on their own,
with a blank line before and after the command, for example
+.PP
.in +4n
-.nf
-
-man 7 man-pages
-
-.fi
+.EX
+man 7 man\-pages
+.EE
.in
+.PP
If the command is short, then it can be included inline in the text,
in italic format, for example,
.IR "man 7 man-pages" .
Again, the use of nonbreaking spaces may be appropriate
if the expression is inlined with normal text.
.PP
-Any reference to the subject of the current manual page
-should be written with the name in bold.
-If the subject is a function (i.e., this is a Section 2 or 3 page),
-then the name should be followed by a pair of parentheses
-in Roman (normal) font.
-For example, in the
-.BR fcntl (2)
-man page, references to the subject of the page would be written as:
-.BR fcntl ().
-The preferred way to write this in the source file is:
-.nf
-
- .BR fcntl ()
-
-.fi
-(Using this format, rather than the use of "\\fB...\\fP()"
-makes it easier to write tools that parse man page source files.)
+When showing example shell sessions, user input should be formatted in bold, for example
+.PP
+.in +4n
+.EX
+$ \fBdate\fP
+Thu Jul 7 13:01:27 CEST 2016
+.EE
+.in
+.PP
.PP
Any reference to another man page
should be written with the name in bold,
separating spaces (e.g.,
.BR intro (2)).
The preferred way to write this in the source file is:
-.nf
-
+.PP
+.EX
.BR intro (2)
-
-.fi
+.EE
+.PP
(Including the section number in cross references lets tools like
.BR man2html (1)
create properly hyperlinked pages.)
-
+.PP
Control characters should be written in bold face,
with no quotes; for example,
.BR ^X .
follows American spelling conventions
(previously, there was a random mix of British and American spellings);
please write all new pages and patches according to these conventions.
-
+.PP
Aside from the well-known spelling differences,
there are a few other subtleties to watch for:
.IP * 3
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
For example:
-
+.PP
+.EX
.SS Unicode under Linux
-
+.EE
+.\"
.SS Indentation of structure definitions, shell session logs, and so on
When structure definitions, shell session logs, and so on are included
in running text, indent them by 4 spaces (i.e., a block enclosed by
.I ".in\ +4n"
and
-.IR ".in" ).
+.IR ".in" ),
+format them using the
+.I .EX
+and
+.I EE
+macros, and surround them with suitable paragraph markers (either
+.I .PP
+or
+.IR .IP ).
+For example:
+.PP
+.in +4n
+.EX
+ .PP
+ .in +4n
+ .EX
+ int
+ main(int argc, char *argv[])
+ {
+ return 0;
+ }
+ .EE
+ .in
+ .PP
+.EE
+.in
.SS Preferred terms
The following table lists some preferred terms to use in man pages,
mainly to ensure consistency across pages.
hostname host name
inode i-node
lowercase lower case, lower-case
+nonzero non-zero
pathname path name
pseudoterminal pseudo-terminal
privileged port T{
usable useable
user space userspace
username user name
+x86-64 x86_64 T{
+Except if referring to result of "uname\ \-m" or similar
+T}
zeros zeroes
.TE
.PP
Use the correct spelling and case for trademarks.
The following is a list of the correct spellings of various
relevant trademarks that are sometimes misspelled:
-
+.PP
DG/UX
HP-UX
UNIX
.IR "null byte",
a byte with the value 0, represented in C via the character constant
.IR \(aq\e0\(aq .
-
+.PP
The preferred term for the pointer is "null pointer" or simply "NULL";
avoid writing "NULL pointer".
-
+.PP
The preferred term for the byte is "null byte".
Avoid writing "NUL", since it is too easily confused with "NULL".
Avoid also the terms "zero byte" and "null character".
.BR groff_man (7)).
This produces proper hyperlinks that can be used in a web browser,
when rendering a page with, say:
-
+.PP
BROWSER=firefox man -H pagename
.SS Use of e.g., i.e., etc., a.k.a., and similar
-In general, the use of abbreviations such as "e.g.", "i.e.", "etc.", "a.k.a."
-should be avoided, in favor of suitable full wordings
-("for example", "that is", "and so on", "also known as").
-
+In general, the use of abbreviations such as "e.g.", "i.e.", "etc.",
+"cf.", and "a.k.a." should be avoided,
+in favor of suitable full wordings
+("for example", "that is", "compare to", "and so on", "also known as").
+.PP
The only place where such abbreviations may be acceptable is in
.I short
parenthetical asides (e.g., like this one).
-
+.PP
Always include periods in such abbreviations, as shown here.
In addition, "e.g." and "i.e." should always be followed by a comma.
.SS Em-dashes
The way to write an em-dash\(emthe glyph that appears
-at either end of this subphrase\(emin *roff is with the macro "\\(em".
+at either end of this subphrase\(emin *roff is with the macro "\e(em".
(On an ASCII terminal, an em-dash typically renders as two hyphens,
but in other typographical contexts it renders as a long dash.)
Em-dashes should be written
.SS Hyphenation of attributive compounds
Compound terms should be hyphenated when used attributively
(i.e., to qualify a following noun). Some examples:
-
+.PP
32-bit value
command-line argument
floating-point number
Manual pages should generally follow this rule when these prefixes are
used in natural English constructions with simple suffixes.
The following list gives some examples of the preferred forms:
-
+.PP
interprocess
multithreaded
multiprocess
subcomponent
subdirectory
subsystem
-
+.PP
Hyphens should be retained when the prefixes are used in nonstandard
English words, with trademarks, proper nouns, acronyms, or compound terms.
Some examples:
-
+.PP
non-ASCII
non-English
non-NULL
non-real-time
-
+.PP
Finally, note that "re-create" and "recreate" are two different verbs,
and the former is probably what you want.
.SS Real minus character
Where a real minus character is required (e.g., for numbers such as \-1,
+for man page cross references such as
+.BR utf\-8 (7),
or when writing options that have a leading dash, such as in
.IR "ls\ \-l"),
use the following form in the man page source:
-
- \\-
-
+.PP
+ \e\-
+.PP
This guideline applies also to code examples.
.SS Character constants
To produce single quotes that render well in both ASCII and UTF-8,
use the following form for character constants in the man page source:
-
- \\(aqC\\(aq
-
+.PP
+ \e(aqC\e(aq
+.PP
where
.I C
is the quoted character.
(Avoid the use of TAB characters in source code!)
The following command can be used to format your source code to
something close to the preferred style:
-
+.IP
indent \-npro \-kr \-i4 \-ts4 \-sob \-l72 \-ss \-nut \-psl prog.c
.IP *
For consistency, all example programs should terminate using either of:
-
+.IP
exit(EXIT_SUCCESS);
exit(EXIT_FAILURE);
-
+.IP
Avoid using the following forms to terminate a program:
-
+.IP
exit(0);
exit(1);
return n;
with a subsection heading
.IR "Program source" ,
as in:
-
+.IP
.SS Program source
-
+.IP
Always do this if the explanatory text includes a shell session log.
.PP
If you include a shell session log demonstrating the use of a program