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