]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man7/man-pages.7
6e4dcfb49aa8a28d06cb00b81f2bab3179374534
[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 .\" 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.
8 .\"
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.
13 .\"
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
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" 2007-05-30 created by mtk, using text from old man.7 plus
26 .\" rewrites and additional text.
27 .\"
28 .TH MAN-PAGES 7 2007-05-30 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 man-pages \- conventions for writing Linux man pages
31 .SH SYNOPSIS
32 .B man
33 .RI [ section ]
34 .I title
35 .SH DESCRIPTION
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
42 .PP
43 The manual Sections are traditionally defined as follows:
44 .TP 10
45 .B 1 Commands (Programs)
46 Those commands that can be executed by the user from within
47 a shell.
48 .TP
49 .B 2 System calls
50 Those functions which must be performed by the kernel.
51 .TP
52 .B 3 Library calls
53 Most of the
54 .I libc
55 functions.
56 .TP
57 .B 4 Special files (devices)
58 Files found in
59 .IR /dev .
60 .TP
61 .B 5 File formats and conventions
62 The format for
63 .I /etc/passwd
64 and other human-readable files.
65 .TP
66 .B 6 Games
67 .TP
68 .B 7 Conventions and miscellaneous
69 Overviews of various topics, conventions and protocols,
70 character set standards, and miscellaneous other things.
71 .TP
72 .B 8 System management commands
73 Commands like
74 .BR mount (8),
75 many of which only root can execute.
76 .\" .TP
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.
84 .SS Macro package
85 New manual pages should be marked up using the
86 .B groff an.tmac
87 package described in
88 .BR man (7).
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
93 wherever possible.
94 This helps avoid line-wrapping in some mail clients when patches are
95 submitted inline.
96
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.
100 .SS Title line
101 The first command in a man page should be a \fBTH\fP command:
102 .RS
103 .sp
104 .B \&.TH
105 .IR "title section date source manual"
106 .sp
107 .RE
108 where:
109 .RS
110 .TP 10
111 .I title
112 The title of the man page, written in all caps (e.g.,
113 .IR MAN-PAGES ).
114 .TP
115 .I section
116 The section number in which the man page should be placed (e.g.,
117 .IR 7 ).
118 .TP
119 .I date
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.
124 .TP
125 .I source
126 The source of the command, function, or system call.
127 .sp
128 For those few \fIman-pages\fP pages in Sections 1 and 8,
129 probably you just want to write
130 .IR GNU .
131 .sp
132 For system calls, just write
133 .IR "Linux" .
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.)
139 .sp
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 ,
143 or an empty string.
144 .sp
145 For Section 4 pages, use
146 .IR "Linux" .
147 .sp
148 In cases of doubt, just write
149 .IR Linux ", or " GNU .
150 .TP
151 .I manual
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" ).
155 .RE
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
159 .B highlighted
160 sections.
161 Arrange a new manual page so that sections
162 are placed in the order shown in the list.
163 .in +0.5i
164 .nf
165
166 \fBNAME\fP
167 \fBSYNOPSIS\fP
168 \fBDESCRIPTION\fP
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,,,
173 .\" ERROR HANDLING,
174 ERRORS [Typically only in Sections 2, 3]
175 .\" May 07: Almost no current man pages have a USAGE section,,,
176 .\" USAGE,
177 .\" DIAGNOSTICS,
178 .\" May 07: Almost no current man pages have a SECURITY section,,,
179 .\" SECURITY,
180 ENVIRONMENT
181 FILES
182 VERSIONS [Normally only in Sections 2, 3]
183 CONFORMING TO
184 NOTES
185 BUGS
186 EXAMPLE
187 .\" AUTHORS sections are discouraged
188 .\" AUTHORS [Discouraged]
189 \fBSEE ALSO\fP
190
191 .fi
192 .in
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
200 those sections.
201
202 The following list elaborates on the contents of each of
203 the above sections.
204 .TP 14
205 .B NAME
206 The name of this manual page.
207 See
208 .BR man (7)
209 for important details of the line(s) that should follow the
210 \fB.SH NAME\fP command.
211 .TP
212 .B SYNOPSIS
213 briefly describes the command or function's interface.
214 For commands, this shows the syntax of the command and its arguments
215 (including options);
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
221 .B #include
222 directives, followed by the function declaration.
223
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
229 .TP
230 .B DESCRIPTION
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
238 .B OPTIONS
239 section.
240 .\" If there is some kind of input grammar or complex set of subcommands,
241 .\" consider describing them in a separate
242 .\" .B USAGE
243 .\" section (and just place an overview in the
244 .\" .B DESCRIPTION
245 .\" section).
246 .TP
247 .B OPTIONS
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.
251 .\" .TP
252 .\" .B USAGE
253 .\" describes the grammar of any sublanguage this implements.
254 .TP
255 .B EXIT STATUS
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.
259 .TP
260 .B RETURN VALUE
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.
264 .TP
265 .B ERRORS
266 For Section 2 and 3 manual pages, this is a list of the
267 values that may be placed in
268 .I errno
269 in the event of an error, along with information about the cause
270 of the errors.
271 .IR "The error list should be in alphabetical order" .
272 .TP
273 .B ENVIRONMENT
274 lists all environment variables that affect the program or function
275 and how they affect it.
276 .TP
277 .B FILES
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
284 .IR /usr/local ,
285 so your base manual page should use
286 .I /usr/local
287 as the base.
288 .\" May 07: Almost no current man pages have a DIAGNOSTICS section;
289 .\" "RETURN VALUE" or "EXIT STATUS" is preferred.
290 .\" .TP
291 .\" .B DIAGNOSTICS
292 .\" gives an overview of the most common error messages and how to
293 .\" cope with them.
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.
297 .\"
298 .\" May 07: Almost no current man pages have a SECURITY section.
299 .\".TP
300 .\".B SECURITY
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
308 .\" .B DESCRIPTION
309 .\" or
310 .\" .B USAGE
311 .\" section).
312 .\" However, please include security information somewhere!
313 .TP
314 .B VERSIONS
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.
318 .TP
319 .B CONFORMING TO
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.)
330 (See
331 .BR standards (7).)
332
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.
336 .TP
337 .B NOTES
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.
341 .TP
342 .B BUGS
343 lists limitations, known defects or inconveniences,
344 and other questionable activities.
345 .TP
346 .B EXAMPLE
347 provides one or more examples describing how this function, file or
348 command is used.
349 For details on writing example programs,
350 see \fIExample Programs\fP below.
351 .TP
352 .B AUTHORS
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.
361 .TP
362 .B SEE ALSO
363 lists related man pages, ordered by section number and
364 then alphabetically by name, possibly followed by
365 other related pages or documents.
366 .SS Font conventions
367 .PP
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:
371 .PP
372 .RS
373 .BI " int myfunction(int " argc ", char **" argv );
374 .RE
375 .PP
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>" ).
380 .PP
381 Special macros, which are usually in upper case, are in bold (e.g.,
382 .BR MAXINT ).
383 Exception: don't boldface NULL.
384 .PP
385 When enumerating a list of error codes, the codes are in bold (this list
386 usually uses the
387 .B \&.TP
388 macro).
389 .PP
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.
395 For example, in the
396 .BR fcntl (2)
397 man page, references to the subject of the page would be written as:
398 .BR fcntl ().
399 The preferred way to write this in the source file is:
400 .nf
401
402 .BR fcntl ()
403
404 .fi
405 (Using this format, rather than the use of "\\fB...\\fP()"
406 makes it easier to write tools that parse man page source files.)
407 .PP
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.,
413 .BR intro (2)).
414 The preferred way to write this in the source file is:
415 .nf
416
417 .BR intro (2)
418
419 .fi
420 (Including the section number in cross references lets tools like
421 .BR man2html (1)
422 create properly hyperlinked pages.)
423 .SS Spelling
424 Starting with release 2.59,
425 .I man-pages
426 follows American spelling conventions;
427 please write all new pages and patches according to these conventions.
428 .SS Example Programs
429 Manual pages can include example programs demonstrating how to
430 use a system call or library function.
431 However, note the following:
432 .TP 3
433 *
434 Example programs should be written in C.
435 .TP
436 *
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.
442 .TP
443 *
444 Example programs should be fairly short (preferably < 100 lines;
445 ideally < 50 lines).
446 .TP
447 *
448 Example programs should do error checking after system calls and
449 library function calls.
450 .TP
451 *
452 Example programs should be complete, and compile without
453 warnings when compiled with \fIcc -Wall\fP.
454 .TP
455 *
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).
460 .TP
461 *
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!)
465 .PP
466 For some examples of what example programs should look like, see
467 .BR wait (2)
468 and
469 .BR pipe (2).
470 .SH EXAMPLE
471 For canonical examples of how man pages in the
472 .IR man-pages
473 package should look, see
474 .BR pipe (2)
475 and
476 .BR fcntl (2).
477 .SH SEE ALSO
478 .BR man (1),
479 .BR man2html (1),
480 .BR groff (7),
481 .BR groff_man (7),
482 .BR man (7),
483 .BR mdoc (7)