]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/man-pages.7
Many pages: Add '\" t' comment where necessary
[thirdparty/man-pages.git] / man7 / man-pages.7
CommitLineData
a1eaacb1 1'\" t
ba83bc0d
MK
2.\" (C) Copyright 1992-1999 Rickard E. Faith and David A. Wheeler
3.\" (faith@cs.unc.edu and dwheeler@ida.org)
c11b1abf 4.\" and (C) Copyright 2007 Michael Kerrisk <mtk.manpages@gmail.com>
ba83bc0d 5.\"
5fbde956 6.\" SPDX-License-Identifier: Linux-man-pages-copyleft
988db661
MK
7.\"
8.\" 2007-05-30 created by mtk, using text from old man.7 plus
04bc8827 9.\" rewrites and additional text.
ba83bc0d 10.\"
06cb0612 11.TH man-pages 7 (date) "Linux man-pages (unreleased)"
ba83bc0d
MK
12.SH NAME
13man-pages \- conventions for writing Linux man pages
14.SH SYNOPSIS
15.B man
16.RI [ section ]
17.I title
18.SH DESCRIPTION
19This page describes the conventions that should be employed
20when writing man pages for the Linux \fIman-pages\fP project,
7aa48d58
MK
21which documents the user-space API provided by the Linux kernel
22and the GNU C library.
23The project thus provides most of the pages in Section 2,
0b920015
MK
24many of the pages that appear in Sections 3, 4, and 7,
25and a few of the pages that appear in Sections 1, 5, and 8
26of the man pages on a Linux system.
ba83bc0d
MK
27The conventions described on this page may also be useful
28for authors writing man pages for other projects.
c634028a 29.SS Sections of the manual pages
ba83bc0d 30The manual Sections are traditionally defined as follows:
0019177e 31.TP
db6642bd 32.B 1 User commands (Programs)
3921205d 33Commands that can be executed by the user from within
ba83bc0d
MK
34a shell.
35.TP
36.B 2 System calls
3921205d 37Functions which wrap operations performed by the kernel.
ba83bc0d
MK
38.TP
39.B 3 Library calls
db6642bd
SA
40All library functions excluding the system call wrappers
41(Most of the
ba83bc0d 42.I libc
db6642bd 43functions).
ba83bc0d
MK
44.TP
45.B 4 Special files (devices)
46Files found in
db6642bd
SA
47.I /dev
48which allow to access to devices through the kernel.
ba83bc0d 49.TP
095f40d5 50.B 5 File formats and configuration files
db6642bd 51Describes various human-readable file formats and configuration files.
ba83bc0d
MK
52.TP
53.B 6 Games
db6642bd 54Games and funny little programs available on the system.
ba83bc0d 55.TP
d6aaae47 56.B 7 Overview, conventions, and miscellaneous
735334d4 57Overviews or descriptions of various topics, conventions, and protocols,
db6642bd
SA
58character set standards, the standard filesystem layout, and miscellaneous
59other things.
ba83bc0d
MK
60.TP
61.B 8 System management commands
62Commands like
63.BR mount (8),
64many of which only root can execute.
65.\" .TP
66.\" .B 9 Kernel routines
67.\" This is an obsolete manual section.
68.\" Once it was thought a good idea to document the Linux kernel here,
69.\" but in fact very little has been documented, and the documentation
70.\" that exists is outdated already.
71.\" There are better sources of
72.\" information for kernel developers.
ba83bc0d
MK
73.SS Macro package
74New manual pages should be marked up using the
add00eab 75.B groff an.tmac
ba83bc0d
MK
76package described in
77.BR man (7).
988db661 78This choice is mainly for consistency: the vast majority of
ba83bc0d
MK
79existing Linux manual pages are marked up using these macros.
80.SS Conventions for source file layout
988db661 81Please limit source code line length to no more than about 75 characters
ba83bc0d
MK
82wherever possible.
83This helps avoid line-wrapping in some mail clients when patches are
84submitted inline.
ba83bc0d 85.SS Title line
aeb9b6a6
MK
86The first command in a man page should be a
87.B TH
88command:
6545cc56 89.PP
ba83bc0d 90.RS
ba83bc0d 91.B \&.TH
7858a277 92.I "title section date source manual-section"
ba83bc0d 93.RE
6545cc56 94.PP
cc863b39 95The arguments of the command are as follows:
4fba3f2a 96.TP
ba83bc0d
MK
97.I title
98The title of the man page, written in all caps (e.g.,
99.IR MAN-PAGES ).
100.TP
101.I section
102The section number in which the man page should be placed (e.g.,
103.IR 7 ).
104.TP
105.I date
1c4b22fb
MK
106The date of the last nontrivial change that was made to the man page.
107(Within the
108.I man-pages
0094f2b0 109project, the necessary updates to these timestamps are handled
1c4b22fb
MK
110automatically by scripts, so there is no need to manually update
111them as part of a patch.)
ba83bc0d
MK
112Dates should be written in the form YYYY-MM-DD.
113.TP
114.I source
7858a277
AC
115The name and version of the project that provides the manual page
116(not necessarily the package that provides the functionality).
ba83bc0d 117.TP
7858a277
AC
118.I manual-section
119Normally, this should be empty,
120since the default value will be good.
4fba3f2a 121.\"
ba83bc0d
MK
122.SS Sections within a manual page
123The list below shows conventional or suggested sections.
988db661 124Most manual pages should include at least the
ba83bc0d
MK
125.B highlighted
126sections.
04bc8827 127Arrange a new manual page so that sections
ba83bc0d 128are placed in the order shown in the list.
9c40f2b9 129.PP
34de771d
MK
130.RS
131.TS
132l l.
ba83bc0d 133\fBNAME\fP
7912be43 134LIBRARY [Normally only in Sections 2, 3]
ba83bc0d 135\fBSYNOPSIS\fP
34de771d 136CONFIGURATION [Normally only in Section 4]
ba83bc0d 137\fBDESCRIPTION\fP
34de771d
MK
138OPTIONS [Normally only in Sections 1, 8]
139EXIT STATUS [Normally only in Sections 1, 8]
140RETURN VALUE [Normally only in Sections 2, 3]
ba83bc0d
MK
141.\" May 07: Few current man pages have an ERROR HANDLING section,,,
142.\" ERROR HANDLING,
34de771d 143ERRORS [Typically only in Sections 2, 3]
ba83bc0d 144.\" May 07: Almost no current man pages have a USAGE section,,,
988db661 145.\" USAGE,
25a46448 146.\" DIAGNOSTICS,
ba83bc0d
MK
147.\" May 07: Almost no current man pages have a SECURITY section,,,
148.\" SECURITY,
149ENVIRONMENT
150FILES
34de771d
MK
151VERSIONS [Normally only in Sections 2, 3]
152ATTRIBUTES [Normally only in Sections 2, 3]
3113c7f3 153STANDARDS
ba83bc0d 154NOTES
cb828372 155CAVEATS
ba83bc0d 156BUGS
005383e6 157EXAMPLES
dcbc136a 158.\" AUTHORS sections are discouraged
34de771d
MK
159AUTHORS [Discouraged]
160REPORTING BUGS [Not used in man-pages]
161COPYRIGHT [Not used in man-pages]
ba83bc0d 162\fBSEE ALSO\fP
34de771d
MK
163.TE
164.RE
e646a1ba 165.PP
ba83bc0d
MK
166.IR "Where a traditional heading would apply" ", " "please use it" ;
167this kind of consistency can make the information easier to understand.
988db661 168If you must, you can create your own
ba83bc0d
MK
169headings if they make things easier to understand (this can
170be especially useful for pages in Sections 4 and 5).
171However, before doing this, consider whether you could use the
172traditional headings, with some subsections (\fI.SS\fP) within
173those sections.
5711c04f 174.PP
988db661 175The following list elaborates on the contents of each of
ba83bc0d 176the above sections.
0019177e 177.TP
ba83bc0d
MK
178.B NAME
179The name of this manual page.
5711c04f 180.IP
988db661 181See
ba83bc0d
MK
182.BR man (7)
183for important details of the line(s) that should follow the
25a46448 184\fB.SH NAME\fP command.
472926d8 185All words in this line (including the word immediately
d1a71985 186following the "\e\-") should be in lowercase,
472926d8
MK
187except where English or technical terminological convention
188dictates otherwise.
ba83bc0d 189.TP
18e6ae0e
AC
190.B LIBRARY
191The library providing a symbol.
192.IP
193It shows the common name of the library,
194and in parentheses,
195the name of the library file
e64493fd
AC
196and, if needed, the linker flag needed to link a program against it:
197.RI ( libfoo "[, " -lfoo ]).
18e6ae0e 198.TP
ba83bc0d 199.B SYNOPSIS
9042e249 200A brief summary of the command or function's interface.
5711c04f 201.IP
ba83bc0d
MK
202For commands, this shows the syntax of the command and its arguments
203(including options);
04bc8827
MK
204boldface is used for as-is text and italics are used to
205indicate replaceable arguments.
ba83bc0d
MK
206Brackets ([]) surround optional arguments, vertical bars (|)
207separate choices, and ellipses (\&...) can be repeated.
208For functions, it shows any required data declarations or
209.B #include
210directives, followed by the function declaration.
5711c04f 211.IP
d0e676ff
MK
212Where a feature test macro must be defined in order to obtain
213the declaration of a function (or a variable) from a header file,
214then the SYNOPSIS should indicate this, as described in
215.BR feature_test_macros (7).
e48efc84 216.\" FIXME . Say something here about compiler options
ba83bc0d 217.TP
c9890844
MK
218.B CONFIGURATION
219Configuration details for a device.
5711c04f 220.IP
33a0ccb2 221This section normally appears only in Section 4 pages.
c9890844 222.TP
ba83bc0d 223.B DESCRIPTION
9042e249 224An explanation of what the program, function, or format does.
5711c04f 225.IP
ba83bc0d
MK
226Discuss how it interacts with files and standard input, and what it
227produces on standard output or standard error.
228Omit internals and implementation details unless they're critical for
229understanding the interface.
230Describe the usual case;
231for information on command-line options of a program use the
232.B OPTIONS
233section.
234.\" If there is some kind of input grammar or complex set of subcommands,
235.\" consider describing them in a separate
236.\" .B USAGE
237.\" section (and just place an overview in the
238.\" .B DESCRIPTION
239.\" section).
5711c04f 240.IP
3c4e1fb2
MK
241When describing new behavior or new flags for
242a system call or library function,
243be careful to note the kernel or C library version
244that introduced the change.
245The preferred method of noting this information for flags is as part of a
246.B .TP
247list, in the following form (here, for a new system call flag):
17b015b5 248.RS 16
3c4e1fb2
MK
249.TP
250.BR XYZ_FLAG " (since Linux 3.7)"
251Description of flag...
252.RE
253.IP
3d1ee497 254Including version information is especially useful to users
3c4e1fb2
MK
255who are constrained to using older kernel or C library versions
256(which is typical in embedded systems, for example).
ba83bc0d
MK
257.TP
258.B OPTIONS
9042e249 259A description of the command-line options accepted by a
ba83bc0d 260program and how they change its behavior.
5711c04f 261.IP
33a0ccb2 262This section should appear only for Section 1 and 8 manual pages.
ba83bc0d
MK
263.\" .TP
264.\" .B USAGE
265.\" describes the grammar of any sublanguage this implements.
ba83bc0d
MK
266.TP
267.B EXIT STATUS
9042e249 268A list of the possible exit status values of a program and
ba83bc0d 269the conditions that cause these values to be returned.
5711c04f 270.IP
33a0ccb2 271This section should appear only for Section 1 and 8 manual pages.
ba83bc0d
MK
272.TP
273.B RETURN VALUE
274For Section 2 and 3 pages, this section gives a
275list of the values the library routine will return to the caller
276and the conditions that cause these values to be returned.
277.TP
278.B ERRORS
279For Section 2 and 3 manual pages, this is a list of the
280values that may be placed in
281.I errno
282in the event of an error, along with information about the cause
283of the errors.
5711c04f 284.IP
520caa55
MK
285Where several different conditions produce the same error,
286the preferred approach is to create separate list entries
287(with duplicate error names) for each of the conditions.
288This makes the separate conditions clear, may make the list easier to read,
289and allows metainformation
290(e.g., kernel version number where the condition first became applicable)
291to be more easily marked for each condition.
5711c04f 292.IP
09f49246 293.IR "The error list should be in alphabetical order" .
ba83bc0d
MK
294.TP
295.B ENVIRONMENT
9042e249 296A list of all environment variables that affect the program or function
ba83bc0d
MK
297and how they affect it.
298.TP
299.B FILES
9042e249 300A list of the files the program or function uses, such as
ba83bc0d
MK
301configuration files, startup files,
302and files the program directly operates on.
5711c04f 303.IP
ba83bc0d
MK
304Give the full pathname of these files, and use the installation
305process to modify the directory part to match user preferences.
306For many programs, the default installation location is in
307.IR /usr/local ,
308so your base manual page should use
309.I /usr/local
310as the base.
311.\" May 07: Almost no current man pages have a DIAGNOSTICS section;
312.\" "RETURN VALUE" or "EXIT STATUS" is preferred.
313.\" .TP
314.\" .B DIAGNOSTICS
315.\" gives an overview of the most common error messages and how to
316.\" cope with them.
317.\" You don't need to explain system error messages
318.\" or fatal signals that can appear during execution of any program
319.\" unless they're special in some way to the program.
320.\"
321.\" May 07: Almost no current man pages have a SECURITY section.
322.\".TP
323.\".B SECURITY
324.\"discusses security issues and implications.
325.\"Warn about configurations or environments that should be avoided,
326.\"commands that may have security implications, and so on, especially
327.\"if they aren't obvious.
328.\"Discussing security in a separate section isn't necessary;
329.\"if it's easier to understand, place security information in the
330.\"other sections (such as the
331.\" .B DESCRIPTION
332.\" or
333.\" .B USAGE
334.\" section).
335.\" However, please include security information somewhere!
336.TP
746e0af1 337.B ATTRIBUTES
361b7ac7
MK
338A summary of various attributes of the function(s) documented on this page.
339See
340.BR attributes (7)
341for further details.
746e0af1 342.TP
ba83bc0d
MK
343.B VERSIONS
344A brief summary of the Linux kernel or glibc versions where a
345system call or library function appeared,
346or changed significantly in its operation.
5711c04f 347.IP
294544e7
MK
348As a general rule, every new interface should
349include a VERSIONS section in its manual page.
350Unfortunately,
351many existing manual pages don't include this information
352(since there was no policy to do so when they were written).
353Patches to remedy this are welcome,
354but, from the perspective of programmers writing new code,
33a0ccb2 355this information probably matters only in the case of kernel
294544e7 356interfaces that have been added in Linux 2.4 or later
b324e17d
AC
357(i.e., changes since Linux 2.2),
358and library functions that have been added to glibc since glibc 2.1
294544e7 359(i.e., changes since glibc 2.0).
5711c04f 360.IP
294544e7
MK
361The
362.BR syscalls (2)
f4b5a0b0
MK
363manual page also provides information about kernel versions
364in which various system calls first appeared.
ba83bc0d 365.TP
3113c7f3 366.B STANDARDS
9042e249 367A description of any standards or conventions that relate to the function
04bc8827 368or command described by the manual page.
5711c04f 369.IP
7849287b
MK
370The preferred terms to use for the various standards are listed as
371headings in
372.BR standards (7).
5711c04f 373.IP
04bc8827
MK
374For a page in Section 2 or 3,
375this section should note the POSIX.1
376version(s) that the call conforms to,
377and also whether the call is specified in C99.
378(Don't worry too much about other standards like SUS, SUSv2, and XPG,
379or the SVr4 and 4.xBSD implementation standards,
380unless the call was specified in those standards,
381but isn't in the current version of POSIX.1.)
5711c04f 382.IP
988db661
MK
383If the call is not governed by any standards but commonly
384exists on other systems, note them.
8382f16d 385If the call is Linux-specific, note this.
5711c04f 386.IP
ebc2edd1
MK
387If this section consists of just a list of standards
388(which it commonly does),
389terminate the list with a period (\(aq.\(aq).
ba83bc0d
MK
390.TP
391.B NOTES
9042e249 392Miscellaneous notes.
5711c04f 393.IP
f8843c2e 394For Section 2 and 3 man pages you may find it useful to include
ba83bc0d 395subsections (\fBSS\fP) named \fILinux Notes\fP and \fIGlibc Notes\fP.
5711c04f 396.IP
3a8bef11 397In Section 2, use the heading
0722a578 398.I "C library/kernel differences"
3a8bef11 399to mark off notes that describe the differences (if any) between
ef4f4031 400the C library wrapper function for a system call and
3a8bef11 401the raw system call interface provided by the kernel.
ba83bc0d 402.TP
cb828372
AC
403.B CAVEATS
404Warnings about typical user misuse of an API,
405that don't constitute an API bug or design defect.
406.TP
ba83bc0d 407.B BUGS
9042e249 408A list of limitations, known defects or inconveniences,
ba83bc0d
MK
409and other questionable activities.
410.TP
005383e6 411.B EXAMPLES
735334d4 412One or more examples demonstrating how this function, file, or
ba83bc0d 413command is used.
5711c04f 414.IP
04bc8827 415For details on writing example programs,
1caf9454 416see \fIExample programs\fP below.
ba83bc0d 417.TP
dcbc136a 418.B AUTHORS
9042e249 419A list of authors of the documentation or program.
5711c04f 420.IP
dcbc136a 421\fBUse of an AUTHORS section is strongly discouraged\fP.
ba83bc0d
MK
422Generally, it is better not to clutter every page with a list
423of (over time potentially numerous) authors;
424if you write or significantly amend a page,
425add a copyright notice as a comment in the source file.
0cc32b69 426If you are the author of a device driver and want to include
f8843c2e 427an address for reporting bugs, place this under the BUGS section.
ba83bc0d 428.TP
c91a4f14
MK
429.B REPORTING BUGS
430The
1ae6b2c7 431.I man-pages
c91a4f14
MK
432project doesn't use a REPORTING BUGS section in manual pages.
433Information on reporting bugs is instead supplied in the
434script-generated COLOPHON section.
435However, various projects do use a REPORTING BUGS section.
365a3f29 436It is recommended to place it near the foot of the page.
c91a4f14 437.TP
88c9c16a
MK
438.B COPYRIGHT
439The
1ae6b2c7 440.I man-pages
88c9c16a
MK
441project doesn't use a COPYRIGHT section in manual pages.
442Copyright information is instead maintained in the page source.
443In pages where this section is present,
444it is recommended to place it near the foot of the page, just above SEE ALSO.
445.TP
ba83bc0d 446.B SEE ALSO
9042e249 447A comma-separated list of related man pages, possibly followed by
ba83bc0d 448other related pages or documents.
5711c04f 449.IP
9042e249 450The list should be ordered by section number and
2b917159 451then alphabetically by name.
d2d136f7 452Do not terminate this list with a period.
c92b6bb5
MK
453.IP
454Where the SEE ALSO list contains many long manual page names,
455to improve the visual result of the output, it may be useful to employ the
456.I .ad l
457(don't right justify)
458and
459.I .nh
97776844 460(don't hyphenate)
c92b6bb5 461directives.
4eaa04c5 462Hyphenation of individual page names can be prevented
d1a71985 463by preceding words with the string "\e%".
5711c04f 464.IP
aeb666ce
MK
465Given the distributed, autonomous nature of FOSS projects
466and their documentation, it is sometimes necessary\(emand in many cases
467desirable\(emthat the SEE ALSO section includes references to
468manual pages provided by other projects.
fa28110c
MK
469.SH FORMATTING AND WORDING CONVENTIONS
470The following subsections note some details for preferred formatting and
471wording conventions in various sections of the pages in the
1ae6b2c7 472.I man-pages
fa28110c
MK
473project.
474.SS SYNOPSIS
475Wrap the function prototype(s) in a
476.IR .nf / .fi
477pair to prevent filling.
478.PP
479In general, where more than one function prototype is shown in the SYNOPSIS,
480the prototypes should
481.I not
482be separated by blank lines.
483However, blank lines (achieved using
484.IR .PP )
485may be added in the following cases:
22356d97 486.IP \(bu 3
ff822ed1 487to separate long lists of function prototypes into related groups
fa28110c
MK
488(see for example
489.BR list (3));
22356d97 490.IP \(bu
fa28110c
MK
491in other cases that may improve readability.
492.PP
493In the SYNOPSIS, a long function prototype may need to be
494continued over to the next line.
495The continuation line is indented according to the following rules:
22356d97 496.IP (1) 5
fa28110c
MK
497If there is a single such prototype that needs to be continued,
498then align the continuation line so that when the page is
499rendered on a fixed-width font device (e.g., on an xterm) the
500continuation line starts just below the start of the argument
5e833e27
MK
501list in the line above.
502(Exception: the indentation may be
fa28110c
MK
503adjusted if necessary to prevent a very long continuation line
504or a further continuation line where the function prototype is
505very long.)
506As an example:
22356d97
AC
507.IP
508.in +4n
fa28110c
MK
509.nf
510.BI "int tcsetattr(int " fd ", int " optional_actions ,
511.BI " const struct termios *" termios_p );
512.fi
22356d97
AC
513.in
514.IP (2)
fa28110c
MK
515But, where multiple functions in the SYNOPSIS require
516continuation lines, and the function names have different
517lengths, then align all continuation lines to start in the
5e833e27
MK
518same column.
519This provides a nicer rendering in PDF output
fa28110c
MK
520(because the SYNOPSIS uses a variable width font where
521spaces render narrower than most characters).
522As an example:
c30a612a
AC
523.IP
524.in +4n
fa28110c
MK
525.nf
526.BI "int getopt(int " argc ", char * const " argv[] ,
527.BI " const char *" optstring );
528.BI "int getopt_long(int " argc ", char * const " argv[] ,
529.BI " const char *" optstring ,
530.BI " const struct option *" longopts ", int *" longindex );
531.fi
c30a612a 532.in
fa28110c
MK
533.SS RETURN VALUE
534The preferred wording to describe how
535.I errno
536is set is
537.RI \(dq errno
538is set to indicate the error"
539or similar.
540.\" Before man-pages 5.11, many different wordings were used, which
384a1bb2 541.\" was confusing, and potentially made scripted edits more difficult.
fa28110c
MK
542This wording is consistent with the wording used in both POSIX.1 and FreeBSD.
543.SS ATTRIBUTES
544.\" See man-pages commit c466875ecd64ed3d3cd3e578406851b7dfb397bf
545Note the following:
22356d97 546.IP \(bu 3
fa28110c
MK
547Wrap the table in this section in a
548.IR ".ad\ l" / .ad
549pair to disable text filling and a
550.IR .nh / .hy
551pair to disable hyphenation.
22356d97 552.IP \(bu
fa28110c
MK
553Ensure that the table occupies the full page width through the use of an
554.I lbx
555description for one of the columns
556(usually the first column,
557though in some cases the last column if it contains a lot of text).
22356d97 558.IP \(bu
fa28110c
MK
559Make free use of
560.IR T{ / T}
0efacbdd 561macro pairs to allow table cells to be broken over multiple lines
fa28110c
MK
562(also bearing in mind that pages may sometimes be rendered to a
563width of less than 80 columns).
564.PP
565For examples of all of the above, see the source code of various pages.
7849287b 566.SH STYLE GUIDE
9730fd84 567The following subsections describe the preferred style for the
1ae6b2c7 568.I man-pages
7849287b
MK
569project.
570For details not covered below, the Chicago Manual of Style
9730fd84
MK
571is usually a good source;
572try also grepping for preexisting usage in the project source tree.
7849287b
MK
573.SS Use of gender-neutral language
574As far as possible, use gender-neutral language in the text of man
aa89a58e 575pages.
7849287b 576Use of "they" ("them", "themself", "their") as a gender-neutral singular
9730fd84 577pronoun is acceptable.
c0ada844 578.\"
741abfa1 579.SS Formatting conventions for manual pages describing commands
741abfa1 580For manual pages that describe a command (typically in Sections 1 and 8),
c0ada844
MK
581the arguments are always specified using italics,
582.IR "even in the SYNOPSIS section" .
5711c04f 583.PP
c0ada844
MK
584The name of the command, and its options, should
585always be formatted in bold.
586.\"
587.SS Formatting conventions for manual pages describing functions
588For manual pages that describe functions (typically in Sections 2 and 3),
589the arguments are always specified using italics,
ba83bc0d
MK
590.IR "even in the SYNOPSIS section" ,
591where the rest of the function is specified in bold:
592.PP
ba83bc0d 593.BI " int myfunction(int " argc ", char **" argv );
ba83bc0d 594.PP
027ebd3c 595Variable names should, like argument names, be specified in italics.
5711c04f 596.PP
c0ada844
MK
597Any reference to the subject of the current manual page
598should be written with the name in bold followed by
599a pair of parentheses in Roman (normal) font.
600For example, in the
601.BR fcntl (2)
602man page, references to the subject of the page would be written as:
603.BR fcntl ().
604The preferred way to write this in the source file is:
9c40f2b9
MK
605.PP
606.EX
c0ada844 607 .BR fcntl ()
9c40f2b9
MK
608.EE
609.PP
d1a71985 610(Using this format, rather than the use of "\efB...\efP()"
c0ada844
MK
611makes it easier to write tools that parse man page source files.)
612.\"
4dfeb670
MK
613.SS Use semantic newlines
614In the source of a manual page,
615new sentences should be started on new lines,
6ff6f43d
AC
616long sentences should be split into lines at clause breaks
617(commas, semicolons, colons, and so on),
618and long clauses should be split at phrase boundaries.
4dfeb670
MK
619This convention, sometimes known as "semantic newlines",
620makes it easier to see the effect of patches,
6ff6f43d 621which often operate at the level of
c8d99e2c 622individual sentences, clauses, or phrases.
4dfeb670 623.\"
48fea6de
AC
624.SS Lists
625There are different kinds of lists:
626.TP
627Tagged paragraphs
628These are used for a list of tags and their descriptions.
629When the tags are constants (either macros or numbers)
630they are in bold.
631Use the
632.B .TP
633macro.
634.IP
635An example is this "Tagged paragraphs" subsection is itself.
636.TP
637Ordered lists
13bae3d4 638Elements are preceded by a number in parentheses (1), (2).
48fea6de
AC
639These represent a set of steps that have an order.
640.IP
641When there are substeps,
642they will be numbered like (4.2).
643.TP
644Positional lists
13bae3d4 645Elements are preceded by a number (index) in square brackets [4], [5].
48fea6de
AC
646These represent fields in a set.
647The first index will be:
648.IP
649.RS
650.PD 0
651.TP
652.B 0
653When it represents fields of a C data structure,
654to be consistent with arrays.
655.TP
656.B 1
657When it represents fields of a file,
658to be consistent with tools like
659.BR cut (1).
660.PD
661.RE
662.TP
663Alternatives list
13bae3d4 664Elements are preceded by a letter in parentheses (a), (b).
48fea6de
AC
665These represent a set of (normally) exclusive alternatives.
666.TP
667Bullet lists
13bae3d4 668Elements are preceded by bullet symbols
48fea6de
AC
669.RB ( \e(bu ).
670Anything that doesn't fit elsewhere is
671usually covered by this type of list.
672.TP
673Numbered notes
674Not really a list,
675but the syntax is identical to "positional lists".
676.PP
677There should always be exactly
6782 spaces between the list symbol and the elements.
679This doesn't apply to "tagged paragraphs",
680which use the default indentation rules.
681.\"
c0ada844 682.SS Formatting conventions (general)
724ca69c
MK
683Paragraphs should be separated by suitable markers (usually either
684.I .PP
685or
686.IR .IP ).
687Do
688.I not
689separate paragraphs using blank lines, as this results in poor rendering
690in some output formats (such as PostScript and PDF).
691.PP
9730fd84 692Filenames (whether pathnames, or references to header files)
fc573e5f
MK
693are always in italics (e.g.,
694.IR <stdio.h> ),
ba83bc0d
MK
695except in the SYNOPSIS section, where included files are in bold (e.g.,
696.BR "#include <stdio.h>" ).
9730fd84 697When referring to a standard header file include,
f36234fa
MK
698specify the header file surrounded by angle brackets,
699in the usual C way (e.g.,
ab9616d3 700.IR <stdio.h> ).
ba83bc0d 701.PP
efaef3da 702Special macros, which are usually in uppercase, are in bold (e.g.,
ba83bc0d
MK
703.BR MAXINT ).
704Exception: don't boldface NULL.
705.PP
706When enumerating a list of error codes, the codes are in bold (this list
707usually uses the
708.B \&.TP
709macro).
5711c04f 710.PP
027ebd3c 711Complete commands should, if long,
9730fd84
MK
712be written as an indented line on their own,
713with a blank line before and after the command, for example
e646a1ba 714.PP
027ebd3c 715.in +4n
e646a1ba 716.EX
c30acaeb 717man 7 man\-pages
e646a1ba 718.EE
027ebd3c 719.in
e646a1ba 720.PP
a4f844c6 721If the command is short, then it can be included inline in the text,
027ebd3c
MK
722in italic format, for example,
723.IR "man 7 man-pages" .
24b74457 724In this case, it may be worth using nonbreaking spaces
6351ebc3 725(\e\(ti) at suitable places in the command.
10850212
MK
726Command options should be written in italics (e.g.,
727.IR \-l ).
027ebd3c
MK
728.PP
729Expressions, if not written on a separate indented line, should
730be specified in italics.
24b74457 731Again, the use of nonbreaking spaces may be appropriate
027ebd3c 732if the expression is inlined with normal text.
5711c04f 733.PP
15f0b7af
AC
734When showing example shell sessions,
735user input should be formatted in bold,
736for example
019d9ee8 737.PP
c0ada844 738.in +4n
019d9ee8
MK
739.EX
740$ \fBdate\fP
741Thu Jul 7 13:01:27 CEST 2016
742.EE
c0ada844 743.in
019d9ee8 744.PP
ba83bc0d
MK
745Any reference to another man page
746should be written with the name in bold,
aeb9b6a6
MK
747.I always
748followed by the section number,
ba83bc0d
MK
749formatted in Roman (normal) font, without any
750separating spaces (e.g.,
751.BR intro (2)).
752The preferred way to write this in the source file is:
9c40f2b9
MK
753.PP
754.EX
ba83bc0d 755 .BR intro (2)
9c40f2b9
MK
756.EE
757.PP
ba83bc0d
MK
758(Including the section number in cross references lets tools like
759.BR man2html (1)
760create properly hyperlinked pages.)
5711c04f 761.PP
7849287b
MK
762Control characters should be written in bold face,
763with no quotes; for example,
9ca13180 764.BR \(haX .
55f7ee2a 765.SS Spelling
9daed026 766Starting with release 2.59,
55f7ee2a 767.I man-pages
91e4f660 768follows American spelling conventions
7849287b 769(previously, there was a random mix of British and American spellings);
55f7ee2a 770please write all new pages and patches according to these conventions.
5711c04f 771.PP
7849287b
MK
772Aside from the well-known spelling differences,
773there are a few other subtleties to watch for:
22356d97 774.IP \(bu 3
28aac7d7 775American English tends to use the forms "backward", "upward", "toward",
7849287b 776and so on
28aac7d7 777rather than the British forms "backwards", "upwards", "towards", and so on.
22356d97 778.IP \(bu
cb7cb648
MK
779Opinions are divided on "acknowledgement" vs "acknowledgment".
780The latter is predominant, but not universal usage in American English.
781POSIX and the BSD license use the former spelling.
782In the Linux man-pages project, we use "acknowledgement".
7849287b
MK
783.SS BSD version numbers
784The classical scheme for writing BSD version numbers is
785.IR x.yBSD ,
786where
787.I x.y
788is the version number (e.g., 4.2BSD).
789Avoid forms such as
790.IR "BSD 4.3" .
159f0403 791.SS Capitalization
7849287b 792In subsection ("SS") headings,
efaef3da 793capitalize the first word in the heading, but otherwise use lowercase,
159f0403
MK
794except where English usage (e.g., proper nouns) or programming
795language requirements (e.g., identifier names) dictate otherwise.
09e311c5 796For example:
5711c04f 797.PP
c30a612a 798.in +4n
9c40f2b9 799.EX
c30a612a 800\&.SS Unicode under Linux
9c40f2b9 801.EE
c30a612a 802.in
787dd4ad 803.\"
f78ed33a 804.SS Indentation of structure definitions, shell session logs, and so on
7849287b
MK
805When structure definitions, shell session logs, and so on are included
806in running text, indent them by 4 spaces (i.e., a block enclosed by
807.I ".in\ +4n"
808and
d6dceb1a
MK
809.IR ".in" ),
810format them using the
811.I .EX
812and
71f5ed97 813.I .EE
d6dceb1a
MK
814macros, and surround them with suitable paragraph markers (either
815.I .PP
816or
817.IR .IP ).
818For example:
819.PP
820.in +4n
821.EX
c30a612a
AC
822\&.PP
823\&.in +4n
824\&.EX
825int
826main(int argc, char *argv[])
827{
828 return 0;
829}
830\&.EE
831\&.in
832\&.PP
d6dceb1a
MK
833.EE
834.in
7849287b
MK
835.SS Preferred terms
836The following table lists some preferred terms to use in man pages,
837mainly to ensure consistency across pages.
0ab815e9 838.ad l
7849287b
MK
839.TS
840l l l
841---
0ab815e9 842l l ll.
7849287b
MK
843Term Avoid using Notes
844
845bit mask bitmask
846built-in builtin
847Epoch epoch T{
848For the UNIX Epoch (00:00:00, 1 Jan 1970 UTC)
849T}
850filename file name
9730fd84 851filesystem file system
7849287b
MK
852hostname host name
853inode i-node
a6ce0ba5 854lowercase lower case, lower-case
777411ae 855nonzero non-zero
7849287b
MK
856pathname path name
857pseudoterminal pseudo-terminal
858privileged port T{
859reserved port,
860system port
861T}
862real-time T{
863realtime,
4a6cd1db 864real time
7849287b
MK
865T}
866run time runtime
867saved set-group-ID T{
868saved group ID,
869saved set-GID
870T}
871saved set-user-ID T{
872saved user ID,
873saved set-UID
874T}
875set-group-ID set-GID, setgid
876set-user-ID set-UID, setuid
877superuser T{
878super user,
879super-user
880T}
644ee9c7
MK
881superblock T{
882super block,
883super-block
884T}
7849287b
MK
885timestamp time stamp
886timezone time zone
a6ce0ba5 887uppercase upper case, upper-case
e03fae06 888usable useable
7849287b
MK
889user space userspace
890username user name
8d4b8846
MK
891x86-64 x86_64 T{
892Except if referring to result of "uname\ \-m" or similar
893T}
7849287b
MK
894zeros zeroes
895.TE
4a6cd1db
DP
896.PP
897See also the discussion
1ae6b2c7 898.I Hyphenation of attributive compounds
9730fd84 899below.
7849287b
MK
900.SS Terms to avoid
901The following table lists some terms to avoid using in man pages,
902along with some suggested alternatives,
903mainly to ensure consistency across pages.
0ab815e9 904.ad l
7849287b
MK
905.TS
906l l l
907---
908l l l.
909Avoid Use instead Notes
910
9730fd84
MK
91132bit 32-bit T{
912same for 8-bit, 16-bit, etc.
913T}
7849287b
MK
914current process calling process T{
915A common mistake made by kernel programmers when writing man pages
916T}
917manpage T{
918man page, manual page
919T}
920minus infinity negative infinity
921non-root unprivileged user
922non-superuser unprivileged user
923nonprivileged unprivileged
924OS operating system
925plus infinity positive infinity
926pty pseudoterminal
7849287b
MK
927tty terminal
928Unices UNIX systems
929Unixes UNIX systems
930.TE
0ab815e9
MK
931.ad
932.\"
7849287b 933.SS Trademarks
aa89a58e
MK
934Use the correct spelling and case for trademarks.
935The following is a list of the correct spellings of various
7849287b 936relevant trademarks that are sometimes misspelled:
4e8858eb
AC
937.IP
938.TS
939l.
940DG/UX
941HP-UX
942UNIX
943UnixWare
944.TE
d96bf5f5 945.SS NULL, NUL, null pointer, and null byte
7849287b 946A
1ae6b2c7 947.I null pointer
7849287b
MK
948is a pointer that points to nothing,
949and is normally indicated by the constant
950.IR NULL .
951On the other hand,
952.I NUL
953is the
1ae6b2c7 954.IR "null byte" ,
7849287b
MK
955a byte with the value 0, represented in C via the character constant
956.IR \(aq\e0\(aq .
5711c04f 957.PP
7849287b
MK
958The preferred term for the pointer is "null pointer" or simply "NULL";
959avoid writing "NULL pointer".
5711c04f 960.PP
7849287b
MK
961The preferred term for the byte is "null byte".
962Avoid writing "NUL", since it is too easily confused with "NULL".
963Avoid also the terms "zero byte" and "null character".
964The byte that terminates a C string should be described
965as "the terminating null byte";
966strings may be described as "null-terminated",
967but avoid the use of "NUL-terminated".
968.SS Hyperlinks
969For hyperlinks, use the
970.IR .UR / .UE
971macro pair
972(see
973.BR groff_man (7)).
974This produces proper hyperlinks that can be used in a web browser,
975when rendering a page with, say:
5711c04f 976.PP
1ae6b2c7
AC
977.in +4n
978.EX
979BROWSER=firefox man -H pagename
980.EE
981.in
7849287b 982.SS Use of e.g., i.e., etc., a.k.a., and similar
9ab7f611
BR
983In general, the use of abbreviations such as "e.g.", "i.e.", "etc.",
984"cf.", and "a.k.a." should be avoided,
985in favor of suitable full wordings
1297d744 986("for example", "that is", "and so on", "compare to", "also known as").
5711c04f 987.PP
7849287b
MK
988The only place where such abbreviations may be acceptable is in
989.I short
990parenthetical asides (e.g., like this one).
5711c04f 991.PP
7849287b
MK
992Always include periods in such abbreviations, as shown here.
993In addition, "e.g." and "i.e." should always be followed by a comma.
994.SS Em-dashes
9730fd84 995The way to write an em-dash\(emthe glyph that appears
d1a71985 996at either end of this subphrase\(emin *roff is with the macro "\e(em".
9730fd84
MK
997(On an ASCII terminal, an em-dash typically renders as two hyphens,
998but in other typographical contexts it renders as a long dash.)
7849287b
MK
999Em-dashes should be written
1000.I without
1001surrounding spaces.
1002.SS Hyphenation of attributive compounds
aa89a58e 1003Compound terms should be hyphenated when used attributively
4a6cd1db 1004(i.e., to qualify a following noun). Some examples:
4e8858eb
AC
1005.IP
1006.TS
1007l.
100832-bit value
1009command-line argument
1010floating-point number
1011run-time check
1012user-space function
1013wide-character string
1014.TE
7849287b
MK
1015.SS Hyphenation with multi, non, pre, re, sub, and so on
1016The general tendency in modern English is not to hyphenate
1017after prefixes such as "multi", "non", "pre", "re", "sub", and so on.
1018Manual pages should generally follow this rule when these prefixes are
1019used in natural English constructions with simple suffixes.
1020The following list gives some examples of the preferred forms:
4e8858eb
AC
1021.IP
1022.TS
1023l.
1024interprocess
1025multithreaded
1026multiprocess
1027nonblocking
1028nondefault
1029nonempty
1030noninteractive
1031nonnegative
1032nonportable
1033nonzero
1034preallocated
1035precreate
1036prerecorded
1037reestablished
1038reinitialize
1039rearm
1040reread
1041subcomponent
1042subdirectory
1043subsystem
1044.TE
5711c04f 1045.PP
7849287b
MK
1046Hyphens should be retained when the prefixes are used in nonstandard
1047English words, with trademarks, proper nouns, acronyms, or compound terms.
1048Some examples:
4e8858eb
AC
1049.IP
1050.TS
1051l.
1052non-ASCII
1053non-English
1054non-NULL
1055non-real-time
1056.TE
5711c04f 1057.PP
7849287b
MK
1058Finally, note that "re-create" and "recreate" are two different verbs,
1059and the former is probably what you want.
5daacbdb
MK
1060.\"
1061.SS Generating optimal glyphs
9f0e82b4 1062Where a real minus character is required (e.g., for numbers such as \-1,
e789e07c
BR
1063for man page cross references such as
1064.BR utf\-8 (7),
9730fd84
MK
1065or when writing options that have a leading dash, such as in
1066.IR "ls\ \-l"),
4a6cd1db 1067use the following form in the man page source:
5711c04f 1068.PP
1ae6b2c7
AC
1069.in +4n
1070.EX
1071\e\-
1072.EE
1073.in
5711c04f 1074.PP
7849287b 1075This guideline applies also to code examples.
5daacbdb 1076.PP
fe1ab0bc
MK
1077The use of real minus signs serves the following purposes:
1078.\" https://lore.kernel.org/linux-man/20210121061158.5ul7226fgbrmodbt@localhost.localdomain/
22356d97 1079.IP \(bu 3
fe1ab0bc
MK
1080To provide better renderings on various targets other than
1081ASCII terminals,
1082notably in PDF and on Unicode/UTF\-8-capable terminals.
22356d97 1083.IP \(bu
fe1ab0bc
MK
1084To generate glyphs that when copied from rendered pages will
1085produce real minus signs when pasted into a terminal.
1086.PP
5daacbdb
MK
1087To produce unslanted single quotes that render well in ASCII, UTF-8, and PDF,
1088use "\e(aq" ("apostrophe quote"); for example
5711c04f 1089.PP
1ae6b2c7
AC
1090.in +4n
1091.EX
1092\e(aqC\e(aq
1093.EE
1094.in
5711c04f 1095.PP
7849287b
MK
1096where
1097.I C
1098is the quoted character.
1099This guideline applies also to character constants used in code examples.
5daacbdb
MK
1100.PP
1101Where a proper caret (\(ha) that renders well in both a terminal and PDF
1102is required, use "\\(ha".
1103This is especially necessary in code samples,
1104to get a nicely rendered caret when rendering to PDF.
1105.PP
1106Using a naked "\(ti" character results in a poor rendering in PDF.
1107Instead use "\\(ti".
1108This is especially necessary in code samples,
1109to get a nicely rendered tilde when rendering to PDF.
1110.\"
c634028a 1111.SS Example programs and shell sessions
9730fd84 1112Manual pages may include example programs demonstrating how to
ba83bc0d
MK
1113use a system call or library function.
1114However, note the following:
22356d97 1115.IP \(bu 3
ba83bc0d 1116Example programs should be written in C.
22356d97 1117.IP \(bu
33a0ccb2 1118An example program is necessary and useful only if it demonstrates
ba83bc0d
MK
1119something beyond what can easily be provided in a textual
1120description of the interface.
1121An example program that does nothing
1122other than call an interface usually serves little purpose.
22356d97 1123.IP \(bu
6e684417
MK
1124Example programs should ideally be short
1125(e.g., a good example can often be provided in less than 100 lines of code),
1126though in some cases longer programs may be necessary
1127to properly illustrate the use of an API.
22356d97 1128.IP \(bu
f18f9c40 1129Expressive code is appreciated.
22356d97 1130.IP \(bu
f18f9c40
MK
1131Comments should included where helpful.
1132Complete sentences in free-standing comments should be
1133terminated by a period.
1134Periods should generally be omitted in "tag" comments
1135(i.e., comments that are placed on the same line of code);
1136such comments are in any case typically brief phrases
1137rather than complete sentences.
22356d97 1138.IP \(bu
ba83bc0d
MK
1139Example programs should do error checking after system calls and
1140library function calls.
22356d97 1141.IP \(bu
ba83bc0d 1142Example programs should be complete, and compile without
5b8dbfd4 1143warnings when compiled with \fIcc\ \-Wall\fP.
22356d97 1144.IP \(bu
ba83bc0d 1145Where possible and appropriate, example programs should allow
d9bfdb9c 1146experimentation, by varying their behavior based on inputs
ba83bc0d
MK
1147(ideally from command-line arguments, or alternatively, via
1148input read by the program).
22356d97 1149.IP \(bu
ba83bc0d 1150Example programs should be laid out according to Kernighan and
5998eb25 1151Ritchie style, with 4-space indents.
ba83bc0d 1152(Avoid the use of TAB characters in source code!)
b1f800c6 1153The following command can be used to format your source code to
d0b8a20c 1154something close to the preferred style:
5711c04f 1155.IP
1ae6b2c7
AC
1156.in +4n
1157.EX
1158indent \-npro \-kr \-i4 \-ts4 \-sob \-l72 \-ss \-nut \-psl prog.c
1159.EE
1160.in
22356d97 1161.IP \(bu
4a6cd1db 1162For consistency, all example programs should terminate using either of:
5711c04f 1163.IP
1ae6b2c7
AC
1164.in +4n
1165.EX
1166exit(EXIT_SUCCESS);
1167exit(EXIT_FAILURE);
1168.EE
1169.in
5711c04f 1170.IP
7849287b 1171Avoid using the following forms to terminate a program:
5711c04f 1172.IP
1ae6b2c7
AC
1173.in +4n
1174.EX
1175exit(0);
1176exit(1);
1177return n;
1178.EE
1179.in
22356d97 1180.IP \(bu
f78f2def
MK
1181If there is extensive explanatory text before the
1182program source code, mark off the source code
d50ee7fb 1183with a subsection heading
f78f2def
MK
1184.IR "Program source" ,
1185as in:
5711c04f 1186.IP
4e8858eb
AC
1187.in +4n
1188.EX
1189\&.SS Program source
1190.EE
1191.in
5711c04f 1192.IP
f78f2def
MK
1193Always do this if the explanatory text includes a shell session log.
1194.PP
1195If you include a shell session log demonstrating the use of a program
1196or other system feature:
22356d97 1197.IP \(bu 3
f08b9d80 1198Place the session log above the source code listing.
22356d97 1199.IP \(bu
f78f2def 1200Indent the session log by four spaces.
22356d97 1201.IP \(bu
f78f2def
MK
1202Boldface the user input text,
1203to distinguish it from output produced by the system.
ba83bc0d
MK
1204.PP
1205For some examples of what example programs should look like, see
1206.BR wait (2)
1207and
1208.BR pipe (2).
a14af333 1209.SH EXAMPLES
ba83bc0d 1210For canonical examples of how man pages in the
0daa9e92 1211.I man-pages
ba83bc0d
MK
1212package should look, see
1213.BR pipe (2)
1214and
1215.BR fcntl (2).
1216.SH SEE ALSO
1217.BR man (1),
1218.BR man2html (1),
5e511b39 1219.BR attributes (7),
976093f0
MK
1220.BR groff (7),
1221.BR groff_man (7),
ba83bc0d
MK
1222.BR man (7),
1223.BR mdoc (7)