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