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>
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.
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.
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
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" 2007-05-30 created by mtk, using text from old man.7 plus
28 .\" rewrites and additional text.
30 .TH MAN-PAGES 7 2016-07-17 "Linux" "Linux Programmer's Manual"
32 man-pages \- conventions for writing Linux man pages
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
50 The manual Sections are traditionally defined as follows:
52 .B 1 User commands (Programs)
53 Those commands that can be executed by the user from within
57 Those functions which wrap operations performed by the kernel.
60 All library functions excluding the system call wrappers
65 .B 4 Special files (devices)
68 which allow to access to devices through the kernel.
70 .B 5 File formats and configuration files
71 Describes various human-readable file formats and configuration files.
74 Games and funny little programs available on the system.
76 .B 7 Overview, conventions, and miscellaneous
77 Overviews or descriptions of various topics, conventions and protocols,
78 character set standards, the standard filesystem layout, and miscellaneous
81 .B 8 System management commands
84 many of which only root can execute.
86 .\" .B 9 Kernel routines
87 .\" This is an obsolete manual section.
88 .\" Once it was thought a good idea to document the Linux kernel here,
89 .\" but in fact very little has been documented, and the documentation
90 .\" that exists is outdated already.
91 .\" There are better sources of
92 .\" information for kernel developers.
94 New manual pages should be marked up using the
98 This choice is mainly for consistency: the vast majority of
99 existing Linux manual pages are marked up using these macros.
100 .SS Conventions for source file layout
101 Please limit source code line length to no more than about 75 characters
103 This helps avoid line-wrapping in some mail clients when patches are
106 New sentences should be started on new lines.
107 This makes it easier to see the effect of patches,
108 which often operate at the level of individual sentences.
110 The first command in a man page should be a
116 .I "title section date source manual"
123 The title of the man page, written in all caps (e.g.,
127 The section number in which the man page should be placed (e.g.,
131 The date of the last nontrivial change that was made to the man page.
134 project, the necessary updates to these timestamps are handled
135 automatically by scripts, so there is no need to manually update
136 them as part of a patch.)
137 Dates should be written in the form YYYY-MM-DD.
140 The source of the command, function, or system call.
142 For those few \fIman-pages\fP pages in Sections 1 and 8,
143 probably you just want to write
146 For system calls, just write
148 (An earlier practice was to write the version number
149 of the kernel from which the manual page was being written/checked.
150 However, this was never done consistently, and so was
151 probably worse than including no version number.
152 Henceforth, avoid including a version number.)
154 For library calls that are part of glibc or one of the
155 other common GNU libraries, just use
156 .IR "GNU C Library" ", " GNU ,
159 For Section 4 pages, use
162 In cases of doubt, just write
163 .IR Linux ", or " GNU .
166 The title of the manual (e.g., for Section 2 and 3 pages in
167 the \fIman-pages\fP package, use
168 .IR "Linux Programmer's Manual" ).
170 .SS Sections within a manual page
171 The list below shows conventional or suggested sections.
172 Most manual pages should include at least the
175 Arrange a new manual page so that sections
176 are placed in the order shown in the list.
182 CONFIGURATION [Normally only in Section 4]
184 OPTIONS [Normally only in Sections 1, 8]
185 EXIT STATUS [Normally only in Sections 1, 8]
186 RETURN VALUE [Normally only in Sections 2, 3]
187 .\" May 07: Few current man pages have an ERROR HANDLING section,,,
189 ERRORS [Typically only in Sections 2, 3]
190 .\" May 07: Almost no current man pages have a USAGE section,,,
193 .\" May 07: Almost no current man pages have a SECURITY section,,,
197 VERSIONS [Normally only in Sections 2, 3]
198 ATTRIBUTES [Normally only in Sections 2, 3]
203 .\" AUTHORS sections are discouraged
204 .\" AUTHORS [Discouraged]
209 .IR "Where a traditional heading would apply" ", " "please use it" ;
210 this kind of consistency can make the information easier to understand.
211 If you must, you can create your own
212 headings if they make things easier to understand (this can
213 be especially useful for pages in Sections 4 and 5).
214 However, before doing this, consider whether you could use the
215 traditional headings, with some subsections (\fI.SS\fP) within
218 The following list elaborates on the contents of each of
222 The name of this manual page.
226 for important details of the line(s) that should follow the
227 \fB.SH NAME\fP command.
228 All words in this line (including the word immediately
229 following the "\\\-") should be in lowercase,
230 except where English or technical terminological convention
234 A brief summary of the command or function's interface.
236 For commands, this shows the syntax of the command and its arguments
238 boldface is used for as-is text and italics are used to
239 indicate replaceable arguments.
240 Brackets ([]) surround optional arguments, vertical bars (|)
241 separate choices, and ellipses (\&...) can be repeated.
242 For functions, it shows any required data declarations or
244 directives, followed by the function declaration.
246 Where a feature test macro must be defined in order to obtain
247 the declaration of a function (or a variable) from a header file,
248 then the SYNOPSIS should indicate this, as described in
249 .BR feature_test_macros (7).
250 .\" FIXME . Say something here about compiler options
253 Configuration details for a device.
255 This section normally appears only in Section 4 pages.
258 An explanation of what the program, function, or format does.
260 Discuss how it interacts with files and standard input, and what it
261 produces on standard output or standard error.
262 Omit internals and implementation details unless they're critical for
263 understanding the interface.
264 Describe the usual case;
265 for information on command-line options of a program use the
268 .\" If there is some kind of input grammar or complex set of subcommands,
269 .\" consider describing them in a separate
271 .\" section (and just place an overview in the
275 When describing new behavior or new flags for
276 a system call or library function,
277 be careful to note the kernel or C library version
278 that introduced the change.
279 The preferred method of noting this information for flags is as part of a
281 list, in the following form (here, for a new system call flag):
284 .BR XYZ_FLAG " (since Linux 3.7)"
285 Description of flag...
288 Including version information is especially useful to users
289 who are constrained to using older kernel or C library versions
290 (which is typical in embedded systems, for example).
293 A description of the command-line options accepted by a
294 program and how they change its behavior.
296 This section should appear only for Section 1 and 8 manual pages.
299 .\" describes the grammar of any sublanguage this implements.
302 A list of the possible exit status values of a program and
303 the conditions that cause these values to be returned.
305 This section should appear only for Section 1 and 8 manual pages.
308 For Section 2 and 3 pages, this section gives a
309 list of the values the library routine will return to the caller
310 and the conditions that cause these values to be returned.
313 For Section 2 and 3 manual pages, this is a list of the
314 values that may be placed in
316 in the event of an error, along with information about the cause
319 .IR "The error list should be in alphabetical order" .
322 A list of all environment variables that affect the program or function
323 and how they affect it.
326 A list of the files the program or function uses, such as
327 configuration files, startup files,
328 and files the program directly operates on.
330 Give the full pathname of these files, and use the installation
331 process to modify the directory part to match user preferences.
332 For many programs, the default installation location is in
334 so your base manual page should use
337 .\" May 07: Almost no current man pages have a DIAGNOSTICS section;
338 .\" "RETURN VALUE" or "EXIT STATUS" is preferred.
341 .\" gives an overview of the most common error messages and how to
343 .\" You don't need to explain system error messages
344 .\" or fatal signals that can appear during execution of any program
345 .\" unless they're special in some way to the program.
347 .\" May 07: Almost no current man pages have a SECURITY section.
350 .\"discusses security issues and implications.
351 .\"Warn about configurations or environments that should be avoided,
352 .\"commands that may have security implications, and so on, especially
353 .\"if they aren't obvious.
354 .\"Discussing security in a separate section isn't necessary;
355 .\"if it's easier to understand, place security information in the
356 .\"other sections (such as the
361 .\" However, please include security information somewhere!
364 A summary of various attributes of the function(s) documented on this page.
370 A brief summary of the Linux kernel or glibc versions where a
371 system call or library function appeared,
372 or changed significantly in its operation.
374 As a general rule, every new interface should
375 include a VERSIONS section in its manual page.
377 many existing manual pages don't include this information
378 (since there was no policy to do so when they were written).
379 Patches to remedy this are welcome,
380 but, from the perspective of programmers writing new code,
381 this information probably matters only in the case of kernel
382 interfaces that have been added in Linux 2.4 or later
383 (i.e., changes since kernel 2.2),
384 and library functions that have been added to glibc since version 2.1
385 (i.e., changes since glibc 2.0).
389 manual page also provides information about kernel versions
390 in which various system calls first appeared.
393 A description of any standards or conventions that relate to the function
394 or command described by the manual page.
396 The preferred terms to use for the various standards are listed as
400 For a page in Section 2 or 3,
401 this section should note the POSIX.1
402 version(s) that the call conforms to,
403 and also whether the call is specified in C99.
404 (Don't worry too much about other standards like SUS, SUSv2, and XPG,
405 or the SVr4 and 4.xBSD implementation standards,
406 unless the call was specified in those standards,
407 but isn't in the current version of POSIX.1.)
409 If the call is not governed by any standards but commonly
410 exists on other systems, note them.
411 If the call is Linux-specific, note this.
413 If this section consists of just a list of standards
414 (which it commonly does),
415 terminate the list with a period (\(aq.\(aq).
420 For Section 2 and 3 man pages you may find it useful to include
421 subsections (\fBSS\fP) named \fILinux Notes\fP and \fIGlibc Notes\fP.
423 In Section 2, use the heading
424 .I "C library/kernel differences"
425 to mark off notes that describe the differences (if any) between
426 the C library wrapper function for a system call and
427 the raw system call interface provided by the kernel.
430 A list of limitations, known defects or inconveniences,
431 and other questionable activities.
434 One or more examples demonstrating how this function, file or
437 For details on writing example programs,
438 see \fIExample Programs\fP below.
441 A list of authors of the documentation or program.
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.
452 A comma-separated list of related man pages, possibly followed by
453 other related pages or documents.
455 The list should be ordered by section number and
456 then alphabetically by name.
457 Do not terminate this list with a period.
459 Where the SEE ALSO list contains many long manual page names,
460 to improve the visual result of the output, it may be useful to employ the
462 (don't right justify)
467 Hyphenation of individual page names can be prevented
468 by preceding words with the string "\\%".
470 Given the distributed, autonomous nature of FOSS projects
471 and their documentation, it is sometimes necessary\(emand in many cases
472 desirable\(emthat the SEE ALSO section includes references to
473 manual pages provided by other projects.
475 The following subsections describe the preferred style for the
478 For details not covered below, the Chicago Manual of Style
479 is usually a good source;
480 try also grepping for preexisting usage in the project source tree.
481 .SS Use of gender-neutral language
482 As far as possible, use gender-neutral language in the text of man
484 Use of "they" ("them", "themself", "their") as a gender-neutral singular
485 pronoun is acceptable.
487 .SS Formatting conventions for manual pages describing functions
489 For manual pages that describe command (typically in Sections 1 and 8),
490 the arguments are always specified using italics,
491 .IR "even in the SYNOPSIS section" .
493 The name of the command, and its options, should
494 always be formatted in bold.
496 .SS Formatting conventions for manual pages describing functions
497 For manual pages that describe functions (typically in Sections 2 and 3),
498 the arguments are always specified using italics,
499 .IR "even in the SYNOPSIS section" ,
500 where the rest of the function is specified in bold:
502 .BI " int myfunction(int " argc ", char **" argv );
504 Variable names should, like argument names, be specified in italics.
506 Any reference to the subject of the current manual page
507 should be written with the name in bold followed by
508 a pair of parentheses in Roman (normal) font.
511 man page, references to the subject of the page would be written as:
513 The preferred way to write this in the source file is:
519 (Using this format, rather than the use of "\\fB...\\fP()"
520 makes it easier to write tools that parse man page source files.)
522 .SS Formatting conventions (general)
523 Filenames (whether pathnames, or references to header files)
524 are always in italics (e.g.,
526 except in the SYNOPSIS section, where included files are in bold (e.g.,
527 .BR "#include <stdio.h>" ).
528 When referring to a standard header file include,
529 specify the header file surrounded by angle brackets,
530 in the usual C way (e.g.,
533 Special macros, which are usually in uppercase, are in bold (e.g.,
535 Exception: don't boldface NULL.
537 When enumerating a list of error codes, the codes are in bold (this list
542 Complete commands should, if long,
543 be written as an indented line on their own,
544 with a blank line before and after the command, for example
552 If the command is short, then it can be included inline in the text,
553 in italic format, for example,
554 .IR "man 7 man-pages" .
555 In this case, it may be worth using nonbreaking spaces
556 ("\e\ ") at suitable places in the command.
557 Command options should be written in italics (e.g.,
560 Expressions, if not written on a separate indented line, should
561 be specified in italics.
562 Again, the use of nonbreaking spaces may be appropriate
563 if the expression is inlined with normal text.
565 When showing example shell sessions, user input should be formatted in bold, for example
570 Thu Jul 7 13:01:27 CEST 2016
574 Any reference to another man page
575 should be written with the name in bold,
577 followed by the section number,
578 formatted in Roman (normal) font, without any
579 separating spaces (e.g.,
581 The preferred way to write this in the source file is:
587 (Including the section number in cross references lets tools like
589 create properly hyperlinked pages.)
591 Control characters should be written in bold face,
592 with no quotes; for example,
595 Starting with release 2.59,
597 follows American spelling conventions
598 (previously, there was a random mix of British and American spellings);
599 please write all new pages and patches according to these conventions.
601 Aside from the well-known spelling differences,
602 there are a few other subtleties to watch for:
604 American English tends to use the forms "backward", "upward", "toward",
606 rather than the British forms "backwards", "upwards", "towards", and so on.
607 .SS BSD version numbers
608 The classical scheme for writing BSD version numbers is
612 is the version number (e.g., 4.2BSD).
616 In subsection ("SS") headings,
617 capitalize the first word in the heading, but otherwise use lowercase,
618 except where English usage (e.g., proper nouns) or programming
619 language requirements (e.g., identifier names) dictate otherwise.
622 .SS Unicode under Linux
624 .SS Indentation of structure definitions, shell session logs, and so on
625 When structure definitions, shell session logs, and so on are included
626 in running text, indent them by 4 spaces (i.e., a block enclosed by
631 The following table lists some preferred terms to use in man pages,
632 mainly to ensure consistency across pages.
637 Term Avoid using Notes
642 For the UNIX Epoch (00:00:00, 1 Jan 1970 UTC)
645 filesystem file system
648 lowercase lower case, lower-case
650 pseudoterminal pseudo-terminal
660 saved set-group-ID T{
668 set-group-ID set-GID, setgid
669 set-user-ID set-UID, setuid
680 uppercase upper case, upper-case
687 See also the discussion
688 .IR "Hyphenation of attributive compounds"
691 The following table lists some terms to avoid using in man pages,
692 along with some suggested alternatives,
693 mainly to ensure consistency across pages.
698 Avoid Use instead Notes
701 same for 8-bit, 16-bit, etc.
703 current process calling process T{
704 A common mistake made by kernel programmers when writing man pages
707 man page, manual page
709 minus infinity negative infinity
710 non-root unprivileged user
711 non-superuser unprivileged user
712 nonprivileged unprivileged
714 plus infinity positive infinity
721 Use the correct spelling and case for trademarks.
722 The following is a list of the correct spellings of various
723 relevant trademarks that are sometimes misspelled:
729 .SS NULL, NUL, null pointer, and null character
732 is a pointer that points to nothing,
733 and is normally indicated by the constant
739 a byte with the value 0, represented in C via the character constant
742 The preferred term for the pointer is "null pointer" or simply "NULL";
743 avoid writing "NULL pointer".
745 The preferred term for the byte is "null byte".
746 Avoid writing "NUL", since it is too easily confused with "NULL".
747 Avoid also the terms "zero byte" and "null character".
748 The byte that terminates a C string should be described
749 as "the terminating null byte";
750 strings may be described as "null-terminated",
751 but avoid the use of "NUL-terminated".
753 For hyperlinks, use the
758 This produces proper hyperlinks that can be used in a web browser,
759 when rendering a page with, say:
761 BROWSER=firefox man -H pagename
762 .SS Use of e.g., i.e., etc., a.k.a., and similar
763 In general, the use of abbreviations such as "e.g.", "i.e.", "etc.", "a.k.a."
764 should be avoided, in favor of suitable full wordings
765 ("for example", "that is", "and so on", "also known as").
767 The only place where such abbreviations may be acceptable is in
769 parenthetical asides (e.g., like this one).
771 Always include periods in such abbreviations, as shown here.
772 In addition, "e.g." and "i.e." should always be followed by a comma.
774 The way to write an em-dash\(emthe glyph that appears
775 at either end of this subphrase\(emin *roff is with the macro "\\(em".
776 (On an ASCII terminal, an em-dash typically renders as two hyphens,
777 but in other typographical contexts it renders as a long dash.)
778 Em-dashes should be written
781 .SS Hyphenation of attributive compounds
782 Compound terms should be hyphenated when used attributively
783 (i.e., to qualify a following noun). Some examples:
786 command-line argument
787 floating-point number
790 wide-character string
791 .SS Hyphenation with multi, non, pre, re, sub, and so on
792 The general tendency in modern English is not to hyphenate
793 after prefixes such as "multi", "non", "pre", "re", "sub", and so on.
794 Manual pages should generally follow this rule when these prefixes are
795 used in natural English constructions with simple suffixes.
796 The following list gives some examples of the preferred forms:
819 Hyphens should be retained when the prefixes are used in nonstandard
820 English words, with trademarks, proper nouns, acronyms, or compound terms.
828 Finally, note that "re-create" and "recreate" are two different verbs,
829 and the former is probably what you want.
830 .SS Real minus character
831 Where a real minus character is required (e.g., for numbers such as \-1,
832 or when writing options that have a leading dash, such as in
834 use the following form in the man page source:
838 This guideline applies also to code examples.
839 .SS Character constants
840 To produce single quotes that render well in both ASCII and UTF-8,
841 use the following form for character constants in the man page source:
847 is the quoted character.
848 This guideline applies also to character constants used in code examples.
849 .SS Example programs and shell sessions
850 Manual pages may include example programs demonstrating how to
851 use a system call or library function.
852 However, note the following:
854 Example programs should be written in C.
856 An example program is necessary and useful only if it demonstrates
857 something beyond what can easily be provided in a textual
858 description of the interface.
859 An example program that does nothing
860 other than call an interface usually serves little purpose.
862 Example programs should be fairly short (preferably less than 100 lines;
863 ideally less than 50 lines).
865 Example programs should do error checking after system calls and
866 library function calls.
868 Example programs should be complete, and compile without
869 warnings when compiled with \fIcc\ \-Wall\fP.
871 Where possible and appropriate, example programs should allow
872 experimentation, by varying their behavior based on inputs
873 (ideally from command-line arguments, or alternatively, via
874 input read by the program).
876 Example programs should be laid out according to Kernighan and
877 Ritchie style, with 4-space indents.
878 (Avoid the use of TAB characters in source code!)
879 The following command can be used to format your source code to
880 something close to the preferred style:
882 indent \-npro \-kr \-i4 \-ts4 \-sob \-l72 \-ss \-nut \-psl prog.c
884 For consistency, all example programs should terminate using either of:
889 Avoid using the following forms to terminate a program:
895 If there is extensive explanatory text before the
896 program source code, mark off the source code
897 with a subsection heading
898 .IR "Program source" ,
903 Always do this if the explanatory text includes a shell session log.
905 If you include a shell session log demonstrating the use of a program
906 or other system feature:
908 Place the session log above the source code listing
910 Indent the session log by four spaces.
912 Boldface the user input text,
913 to distinguish it from output produced by the system.
915 For some examples of what example programs should look like, see
920 For canonical examples of how man pages in the
922 package should look, see