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 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" 2007-05-30 created by mtk, using text from old man.7 plus
26 .\" rewrites and additional text.
28 .TH MAN-PAGES 7 2007-05-30 "Linux" "Linux Programmer's Manual"
30 man-pages \- conventions for writing Linux man pages
36 This page describes the conventions that should be employed
37 when writing man pages for the Linux \fIman-pages\fP project,
38 which comprises Sections 2, 3, 4, 5, and 7 of the Linux manual pages.
39 The conventions described on this page may also be useful
40 for authors writing man pages for other projects.
41 .SS Sections of the Manual Pages
43 The manual Sections are traditionally defined as follows:
45 .B 1 Commands (Programs)
46 Those commands that can be executed by the user from within
50 Those functions which must be performed by the kernel.
57 .B 4 Special files (devices)
61 .B 5 File formats and conventions
64 and other human-readable files.
68 .B 7 Conventions and miscellaneous
69 Overviews of various topics, conventions and protocols,
70 character set standards, and miscellaneous other things.
72 .B 8 System management commands
75 many of which only root can execute.
77 .\" .B 9 Kernel routines
78 .\" This is an obsolete manual section.
79 .\" Once it was thought a good idea to document the Linux kernel here,
80 .\" but in fact very little has been documented, and the documentation
81 .\" that exists is outdated already.
82 .\" There are better sources of
83 .\" information for kernel developers.
85 New manual pages should be marked up using the
89 This choice is mainly for consistency: the vast majority of
90 existing Linux manual pages are marked up using these macros.
91 .SS Conventions for source file layout
92 Please limit source code line length to no more than about 75 characters
94 This helps avoid line-wrapping in some mail clients when patches are
97 New sentences should be started on new lines.
98 This makes it easier to see the effect of patches,
99 which often operate at the level of individual sentences.
101 The first command in a man page should be a \fBTH\fP command:
105 .IR "title section date source manual"
112 The title of the man page, written in all caps (e.g.,
116 The section number in which the man page should be placed (e.g.,
120 The date of the last revision\(emremember to change this every time a
121 change is made to the man page,
122 since this is the most general way of doing version control.
123 Dates should be written in the form YYYY-MM-DD.
126 The source of the command, function, or system call.
128 For those few \fIman-pages\fP pages in Sections 1 and 8,
129 probably you just want to write
132 For system calls, just write
134 (An earlier practice was to write the version number
135 of the kernel from which the manual page was being written/checked.
136 However, this was never done consistently, and so was
137 probably worse than including no version number.
138 Henceforth, avoid including a version number.)
140 For library calls that are part of glibc or one of the
141 other common GNU libraries, just use
142 .IR "GNU C Library" ", " GNU ,
145 For Section 4 pages, use
148 In cases of doubt, just write
149 .IR Linux ", or " GNU .
152 The title of the manual (e.g., for Section 2 and 3 pages in
153 the \fIman-pages\fP package, use
154 .IR "Linux Programmer's Manual" ).
156 .SS Sections within a manual page
157 The list below shows conventional or suggested sections.
158 Most manual pages should include at least the
161 Arrange a new manual page so that sections
162 are placed in the order shown in the list.
169 OPTIONS [Normally only in Sections 1, 8]
170 EXIT STATUS [Normally only in Sections 1, 8]
171 RETURN VALUE [Normally only in Sections 2, 3]
172 .\" May 07: Few current man pages have an ERROR HANDLING section,,,
174 ERRORS [Typically only in Sections 2, 3]
175 .\" May 07: Almost no current man pages have a USAGE section,,,
178 .\" May 07: Almost no current man pages have a SECURITY section,,,
182 VERSIONS [Normally only in Sections 2, 3]
187 .\" AUTHORS sections are discouraged
188 .\" AUTHORS [Discouraged]
193 .IR "Where a traditional heading would apply" ", " "please use it" ;
194 this kind of consistency can make the information easier to understand.
195 If you must, you can create your own
196 headings if they make things easier to understand (this can
197 be especially useful for pages in Sections 4 and 5).
198 However, before doing this, consider whether you could use the
199 traditional headings, with some subsections (\fI.SS\fP) within
202 The following list elaborates on the contents of each of
206 The name of this manual page.
209 for important details of the line(s) that should follow the
210 \fB.SH NAME\fP command.
213 briefly describes the command or function's interface.
214 For commands, this shows the syntax of the command and its arguments
216 boldface is used for as-is text and italics are used to
217 indicate replaceable arguments.
218 Brackets ([]) surround optional arguments, vertical bars (|)
219 separate choices, and ellipses (\&...) can be repeated.
220 For functions, it shows any required data declarations or
222 directives, followed by the function declaration.
224 Where a feature test macro must be defined in order to obtain
225 the declaration of a function (or a variable) from a header file,
226 then the SYNOPSIS should indicate this, as described in
227 .BR feature_test_macros (7).
228 .\" FIXME . Say something here about compiler options
231 gives an explanation of what the program, function, or format does.
232 Discuss how it interacts with files and standard input, and what it
233 produces on standard output or standard error.
234 Omit internals and implementation details unless they're critical for
235 understanding the interface.
236 Describe the usual case;
237 for information on command-line options of a program use the
240 .\" If there is some kind of input grammar or complex set of subcommands,
241 .\" consider describing them in a separate
243 .\" section (and just place an overview in the
248 describes the command-line options accepted by a
249 program and how they change its behavior.
250 This section should only appear for Section 1 and 8 manual pages.
253 .\" describes the grammar of any sublanguage this implements.
256 lists the possible exit status values of a program and
257 the conditions that cause these values to be returned.
258 This section should only appear for Section 1 and 8 manual pages.
261 For Section 2 and 3 pages, this section gives a
262 list of the values the library routine will return to the caller
263 and the conditions that cause these values to be returned.
266 For Section 2 and 3 manual pages, this is a list of the
267 values that may be placed in
269 in the event of an error, along with information about the cause
271 .IR "The error list should be in alphabetical order" .
274 lists all environment variables that affect the program or function
275 and how they affect it.
278 lists the files the program or function uses, such as
279 configuration files, startup files,
280 and files the program directly operates on.
281 Give the full pathname of these files, and use the installation
282 process to modify the directory part to match user preferences.
283 For many programs, the default installation location is in
285 so your base manual page should use
288 .\" May 07: Almost no current man pages have a DIAGNOSTICS section;
289 .\" "RETURN VALUE" or "EXIT STATUS" is preferred.
292 .\" gives an overview of the most common error messages and how to
294 .\" You don't need to explain system error messages
295 .\" or fatal signals that can appear during execution of any program
296 .\" unless they're special in some way to the program.
298 .\" May 07: Almost no current man pages have a SECURITY section.
301 .\"discusses security issues and implications.
302 .\"Warn about configurations or environments that should be avoided,
303 .\"commands that may have security implications, and so on, especially
304 .\"if they aren't obvious.
305 .\"Discussing security in a separate section isn't necessary;
306 .\"if it's easier to understand, place security information in the
307 .\"other sections (such as the
312 .\" However, please include security information somewhere!
315 A brief summary of the Linux kernel or glibc versions where a
316 system call or library function appeared,
317 or changed significantly in its operation.
320 describes any standards or conventions that relate to the function
321 or command described by the manual page.
322 For a page in Section 2 or 3,
323 this section should note the POSIX.1
324 version(s) that the call conforms to,
325 and also whether the call is specified in C99.
326 (Don't worry too much about other standards like SUS, SUSv2, and XPG,
327 or the SVr4 and 4.xBSD implementation standards,
328 unless the call was specified in those standards,
329 but isn't in the current version of POSIX.1.)
333 If the call is not governed by any standards but commonly
334 exists on other systems, note them.
335 If the call is Linux specific, note this.
338 provides miscellaneous notes.
339 For Section 2 and 3 man pages you may find it useful to include
340 subsections (\fBSS\fP) named \fILinux Notes\fP and \fIGlibc Notes\fP.
343 lists limitations, known defects or inconveniences,
344 and other questionable activities.
347 provides one or more examples describing how this function, file or
349 For details on writing example programs,
350 see \fIExample Programs\fP below.
353 lists authors of the documentation or program.
354 \fBUse of an AUTHORS section is strongly discouraged\fP.
355 Generally, it is better not to clutter every page with a list
356 of (over time potentially numerous) authors;
357 if you write or significantly amend a page,
358 add a copyright notice as a comment in the source file.
359 If you are the author of a device driver and want to include
360 an address for reporting bugs, place this under the BUGS section.
363 lists related man pages, ordered by section number and
364 then alphabetically by name, possibly followed by
365 other related pages or documents.
368 For functions, the arguments are always specified using italics,
369 .IR "even in the SYNOPSIS section" ,
370 where the rest of the function is specified in bold:
373 .BI " int myfunction(int " argc ", char **" argv );
376 Filenames are always in italics (e.g.,
377 .IR "/usr/include/stdio.h" ),
378 except in the SYNOPSIS section, where included files are in bold (e.g.,
379 .BR "#include <stdio.h>" ).
381 Special macros, which are usually in upper case, are in bold (e.g.,
383 Exception: don't boldface NULL.
385 When enumerating a list of error codes, the codes are in bold (this list
390 Any reference to the subject of the current manual page
391 should be written with the name in bold.
392 If the subject is a function (i.e., this is a Section 2 or 3 page),
393 then the name should be followed by a pair of parentheses
394 in Roman (normal) font.
397 man page, references to the subject of the page would be written as:
399 The preferred way to write this in the source file is:
405 (Using this format, rather than the use of "\\fB...\\fP()"
406 makes it easier to write tools that parse man page source files.)
408 Any reference to another man page
409 should be written with the name in bold,
410 \fIalways\fP followed by the section number,
411 formatted in Roman (normal) font, without any
412 separating spaces (e.g.,
414 The preferred way to write this in the source file is:
420 (Including the section number in cross references lets tools like
422 create properly hyperlinked pages.)
424 Starting with release 2.59,
426 follows American spelling conventions;
427 please write all new pages and patches according to these conventions.
429 Manual pages can include example programs demonstrating how to
430 use a system call or library function.
431 However, note the following:
434 Example programs should be written in C.
437 An example program is only necessary and useful if it demonstrates
438 something beyond what can easily be provided in a textual
439 description of the interface.
440 An example program that does nothing
441 other than call an interface usually serves little purpose.
444 Example programs should be fairly short (preferably < 100 lines;
448 Example programs should do error checking after system calls and
449 library function calls.
452 Example programs should be complete, and compile without
453 warnings when compiled with \fIcc -Wall\fP.
456 Where possible and appropriate, example programs should allow
457 experimentation, by varying their behavior based on inputs
458 (ideally from command-line arguments, or alternatively, via
459 input read by the program).
462 Example programs should be laid out according to Kernighan and
463 Ritchie style, with 4-space indents.
464 (Avoid the use of TAB characters in source code!)
466 For some examples of what example programs should look like, see
471 For canonical examples of how man pages in the
473 package should look, see