OSDN Git Service

(split) LDP: Update original to LDP v3.52.
[linuxjm/LDP_man-pages.git] / original / 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 .\" %%%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 2013-06-21 "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 as well as many of the pages that appear
44 in Sections 3, 4, 5, and 7 of the man pages on a Linux system.
45 The conventions described on this page may also be useful
46 for authors writing man pages for other projects.
47 .SS Sections of the manual pages
48 .PP
49 The manual Sections are traditionally defined as follows:
50 .TP 10
51 .B 1 Commands (Programs)
52 Those commands that can be executed by the user from within
53 a shell.
54 .TP
55 .B 2 System calls
56 Those functions which must be performed by the kernel.
57 .TP
58 .B 3 Library calls
59 Most of the
60 .I libc
61 functions.
62 .TP
63 .B 4 Special files (devices)
64 Files found in
65 .IR /dev .
66 .TP
67 .B 5 File formats and conventions
68 The format for
69 .I /etc/passwd
70 and other human-readable files.
71 .TP
72 .B 6 Games
73 .TP
74 .B 7 Overview, conventions, and miscellaneous
75 Overviews of various topics, conventions and protocols,
76 character set standards, and miscellaneous other things.
77 .TP
78 .B 8 System management commands
79 Commands like
80 .BR mount (8),
81 many of which only root can execute.
82 .\" .TP
83 .\" .B 9 Kernel routines
84 .\" This is an obsolete manual section.
85 .\" Once it was thought a good idea to document the Linux kernel here,
86 .\" but in fact very little has been documented, and the documentation
87 .\" that exists is outdated already.
88 .\" There are better sources of
89 .\" information for kernel developers.
90 .SS Macro package
91 New manual pages should be marked up using the
92 .B groff an.tmac
93 package described in
94 .BR man (7).
95 This choice is mainly for consistency: the vast majority of
96 existing Linux manual pages are marked up using these macros.
97 .SS Conventions for source file layout
98 Please limit source code line length to no more than about 75 characters
99 wherever possible.
100 This helps avoid line-wrapping in some mail clients when patches are
101 submitted inline.
102
103 New sentences should be started on new lines.
104 This makes it easier to see the effect of patches,
105 which often operate at the level of individual sentences.
106 .SS Title line
107 The first command in a man page should be a
108 .B TH
109 command:
110 .RS
111 .sp
112 .B \&.TH
113 .I "title section date source manual"
114 .sp
115 .RE
116 where:
117 .RS
118 .TP 10
119 .I title
120 The title of the man page, written in all caps (e.g.,
121 .IR MAN-PAGES ).
122 .TP
123 .I section
124 The section number in which the man page should be placed (e.g.,
125 .IR 7 ).
126 .TP
127 .I date
128 The date of the last revision\(emremember to change this every time a
129 change is made to the man page,
130 since this is the most general way of doing version control.
131 Dates should be written in the form YYYY-MM-DD.
132 .TP
133 .I source
134 The source of the command, function, or system call.
135
136 For those few \fIman-pages\fP pages in Sections 1 and 8,
137 probably you just want to write
138 .IR GNU .
139
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.)
147
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.
152
153 For Section 4 pages, use
154 .IR "Linux" .
155
156 In cases of doubt, just write
157 .IR Linux ", or " GNU .
158 .TP
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" ).
163 .RE
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.
171 .in +0.5i
172 .nf
173
174 \fBNAME\fP
175 \fBSYNOPSIS\fP
176 CONFIGURATION      [Normally only in Section 4]
177 \fBDESCRIPTION\fP
178 OPTIONS            [Normally only in Sections 1, 8]
179 EXIT STATUS        [Normally only in Sections 1, 8]
180 RETURN VALUE       [Normally only in Sections 2, 3]
181 .\" May 07: Few current man pages have an ERROR HANDLING section,,,
182 .\" ERROR HANDLING,
183 ERRORS             [Typically only in Sections 2, 3]
184 .\" May 07: Almost no current man pages have a USAGE section,,,
185 .\" USAGE,
186 .\" DIAGNOSTICS,
187 .\" May 07: Almost no current man pages have a SECURITY section,,,
188 .\" SECURITY,
189 ENVIRONMENT
190 FILES
191 ATTRIBUTES         [Normally only in Sections 2, 3]
192 VERSIONS           [Normally only in Sections 2, 3]
193 CONFORMING TO
194 NOTES
195 BUGS
196 EXAMPLE
197 .\" AUTHORS sections are discouraged
198 .\" AUTHORS             [Discouraged]
199 \fBSEE ALSO\fP
200
201 .fi
202 .in
203 .IR "Where a traditional heading would apply" ", " "please use it" ;
204 this kind of consistency can make the information easier to understand.
205 If you must, you can create your own
206 headings if they make things easier to understand (this can
207 be especially useful for pages in Sections 4 and 5).
208 However, before doing this, consider whether you could use the
209 traditional headings, with some subsections (\fI.SS\fP) within
210 those sections.
211
212 The following list elaborates on the contents of each of
213 the above sections.
214 .TP 14
215 .B NAME
216 The name of this manual page.
217 See
218 .BR man (7)
219 for important details of the line(s) that should follow the
220 \fB.SH NAME\fP command.
221 All words in this line (including the word immediately
222 following the "\\\-") should be in lowercase,
223 except where English or technical terminological convention
224 dictates otherwise.
225 .TP
226 .B SYNOPSIS
227 briefly describes the command or function's interface.
228 For commands, this shows the syntax of the command and its arguments
229 (including options);
230 boldface is used for as-is text and italics are used to
231 indicate replaceable arguments.
232 Brackets ([]) surround optional arguments, vertical bars (|)
233 separate choices, and ellipses (\&...) can be repeated.
234 For functions, it shows any required data declarations or
235 .B #include
236 directives, followed by the function declaration.
237
238 Where a feature test macro must be defined in order to obtain
239 the declaration of a function (or a variable) from a header file,
240 then the SYNOPSIS should indicate this, as described in
241 .BR feature_test_macros (7).
242 .\" FIXME . Say something here about compiler options
243 .TP
244 .B CONFIGURATION
245 Configuration details for a device.
246 This section normally appears only in Section 4 pages.
247 .TP
248 .B DESCRIPTION
249 gives an explanation of what the program, function, or format does.
250 Discuss how it interacts with files and standard input, and what it
251 produces on standard output or standard error.
252 Omit internals and implementation details unless they're critical for
253 understanding the interface.
254 Describe the usual case;
255 for information on command-line options of a program use the
256 .B OPTIONS
257 section.
258 .\" If there is some kind of input grammar or complex set of subcommands,
259 .\" consider describing them in a separate
260 .\" .B USAGE
261 .\" section (and just place an overview in the
262 .\" .B DESCRIPTION
263 .\" section).
264 .TP
265 .B OPTIONS
266 describes the command-line options accepted by a
267 program and how they change its behavior.
268 This section should appear only for Section 1 and 8 manual pages.
269 .\" .TP
270 .\" .B USAGE
271 .\" describes the grammar of any sublanguage this implements.
272 .TP
273 .B EXIT STATUS
274 lists the possible exit status values of a program and
275 the conditions that cause these values to be returned.
276 This section should appear only for Section 1 and 8 manual pages.
277 .TP
278 .B RETURN VALUE
279 For Section 2 and 3 pages, this section gives a
280 list of the values the library routine will return to the caller
281 and the conditions that cause these values to be returned.
282 .TP
283 .B ERRORS
284 For Section 2 and 3 manual pages, this is a list of the
285 values that may be placed in
286 .I errno
287 in the event of an error, along with information about the cause
288 of the errors.
289 .IR "The error list should be in alphabetical order" .
290 .TP
291 .B ENVIRONMENT
292 lists all environment variables that affect the program or function
293 and how they affect it.
294 .TP
295 .B FILES
296 lists the files the program or function uses, such as
297 configuration files, startup files,
298 and files the program directly operates on.
299 Give the full pathname of these files, and use the installation
300 process to modify the directory part to match user preferences.
301 For many programs, the default installation location is in
302 .IR /usr/local ,
303 so your base manual page should use
304 .I /usr/local
305 as the base.
306 .\" May 07: Almost no current man pages have a DIAGNOSTICS section;
307 .\"         "RETURN VALUE" or "EXIT STATUS" is preferred.
308 .\" .TP
309 .\" .B DIAGNOSTICS
310 .\" gives an overview of the most common error messages and how to
311 .\" cope with them.
312 .\" You don't need to explain system error messages
313 .\" or fatal signals that can appear during execution of any program
314 .\" unless they're special in some way to the program.
315 .\"
316 .\" May 07: Almost no current man pages have a SECURITY section.
317 .\".TP
318 .\".B SECURITY
319 .\"discusses security issues and implications.
320 .\"Warn about configurations or environments that should be avoided,
321 .\"commands that may have security implications, and so on, especially
322 .\"if they aren't obvious.
323 .\"Discussing security in a separate section isn't necessary;
324 .\"if it's easier to understand, place security information in the
325 .\"other sections (such as the
326 .\" .B DESCRIPTION
327 .\" or
328 .\" .B USAGE
329 .\" section).
330 .\" However, please include security information somewhere!
331 .TP
332 .B ATTRIBUTES
333 A summary of various attributes of the function(s) documented on this page,
334 broken into subsections.
335 The following subsections are defined:
336 .sp
337 .RS
338 .TP
339 .B "Multithreading (see pthreads(7))"
340 This subsection notes attributes relating to multithreaded applications:
341 .RS
342 .IP * 3
343 Whether the function is thread-safe.
344 .IP *
345 Whether the function is a cancellation point.
346 .IP *
347 Whether the function is async-cancel-safe.
348 .RE
349 .IP
350 Details of these attributes can be found in
351 .BR pthreads (7).
352 .RE
353 .TP
354 .B VERSIONS
355 A brief summary of the Linux kernel or glibc versions where a
356 system call or library function appeared,
357 or changed significantly in its operation.
358 As a general rule, every new interface should
359 include a VERSIONS section in its manual page.
360 Unfortunately,
361 many existing manual pages don't include this information
362 (since there was no policy to do so when they were written).
363 Patches to remedy this are welcome,
364 but, from the perspective of programmers writing new code,
365 this information probably matters only in the case of kernel
366 interfaces that have been added in Linux 2.4 or later
367 (i.e., changes since kernel 2.2),
368 and library functions that have been added to glibc since version 2.1
369 (i.e., changes since glibc 2.0).
370
371 The
372 .BR syscalls (2)
373 manual page also provides information about kernel versions
374 in which various system calls first appeared.
375 .TP
376 .B CONFORMING TO
377 describes any standards or conventions that relate to the function
378 or command described by the manual page.
379 For a page in Section 2 or 3,
380 this section should note the POSIX.1
381 version(s) that the call conforms to,
382 and also whether the call is specified in C99.
383 (Don't worry too much about other standards like SUS, SUSv2, and XPG,
384 or the SVr4 and 4.xBSD implementation standards,
385 unless the call was specified in those standards,
386 but isn't in the current version of POSIX.1.)
387 (See
388 .BR standards (7).)
389
390 If the call is not governed by any standards but commonly
391 exists on other systems, note them.
392 If the call is Linux-specific, note this.
393
394 If this section consists of just a list of standards
395 (which it commonly does),
396 terminate the list with a period (\(aq.\(aq).
397 .TP
398 .B NOTES
399 provides miscellaneous notes.
400 For Section 2 and 3 man pages you may find it useful to include
401 subsections (\fBSS\fP) named \fILinux Notes\fP and \fIGlibc Notes\fP.
402 .TP
403 .B BUGS
404 lists limitations, known defects or inconveniences,
405 and other questionable activities.
406 .TP
407 .B EXAMPLE
408 provides one or more examples describing how this function, file or
409 command is used.
410 For details on writing example programs,
411 see \fIExample Programs\fP below.
412 .TP
413 .B AUTHORS
414 lists authors of the documentation or program.
415 \fBUse of an AUTHORS section is strongly discouraged\fP.
416 Generally, it is better not to clutter every page with a list
417 of (over time potentially numerous) authors;
418 if you write or significantly amend a page,
419 add a copyright notice as a comment in the source file.
420 If you are the author of a device driver and want to include
421 an address for reporting bugs, place this under the BUGS section.
422 .TP
423 .B SEE ALSO
424 provides a comma-separated list of related man pages,
425 ordered by section number and
426 then alphabetically by name, possibly followed by
427 other related pages or documents.
428 Do not terminate this with a period.
429 .IP
430 Where the SEE ALSO list contains many long manual page names,
431 to improve the visual result of the output, it may be useful to employ the
432 .I .ad l
433 (don't right justify)
434 and
435 .I .nh
436 (don't hyphenate)
437 directives.
438 Hyphenation of individual page names can be prevented
439 by preceding words with the string "\\%".
440 .SS Font conventions
441 .PP
442 For functions, the arguments are always specified using italics,
443 .IR "even in the SYNOPSIS section" ,
444 where the rest of the function is specified in bold:
445 .PP
446 .BI "    int myfunction(int " argc ", char **" argv );
447 .PP
448 Variable names should, like argument names, be specified in italics.
449 .PP
450 Filenames (whether pathnames, or references to files in the
451 .I /usr/include
452 directory)
453 are always in italics (e.g.,
454 .IR <stdio.h> ),
455 except in the SYNOPSIS section, where included files are in bold (e.g.,
456 .BR "#include <stdio.h>" ).
457 When referring to a standard include file under
458 .IR /usr/include ,
459 specify the header file surrounded by angle brackets,
460 in the usual C way (e.g.,
461 .IR <stdio.h> ).
462 .PP
463 Special macros, which are usually in upper case, are in bold (e.g.,
464 .BR MAXINT ).
465 Exception: don't boldface NULL.
466 .PP
467 When enumerating a list of error codes, the codes are in bold (this list
468 usually uses the
469 .B \&.TP
470 macro).
471 .PP
472 Complete commands should, if long,
473 be written as in an indented line on their own, for example
474 .in +4n
475 .nf
476
477 man 7 man-pages
478
479 .fi
480 .in
481 If the command is short, then it can be included inline in the text,
482 in italic format, for example,
483 .IR "man 7 man-pages" .
484 In this case, it may be worth using nonbreaking spaces
485 ("\e\ ") at suitable places in the command.
486 Command options should be written in italics, e.g.,
487 .IR \-l .
488 .PP
489 Expressions, if not written on a separate indented line, should
490 be specified in italics.
491 Again, the use of nonbreaking spaces may be appropriate
492 if the expression is inlined with normal text.
493 .PP
494 Any reference to the subject of the current manual page
495 should be written with the name in bold.
496 If the subject is a function (i.e., this is a Section 2 or 3 page),
497 then the name should be followed by a pair of parentheses
498 in Roman (normal) font.
499 For example, in the
500 .BR fcntl (2)
501 man page, references to the subject of the page would be written as:
502 .BR fcntl ().
503 The preferred way to write this in the source file is:
504 .nf
505
506     .BR fcntl ()
507
508 .fi
509 (Using this format, rather than the use of "\\fB...\\fP()"
510 makes it easier to write tools that parse man page source files.)
511 .PP
512 Any reference to another man page
513 should be written with the name in bold,
514 .I always
515 followed by the section number,
516 formatted in Roman (normal) font, without any
517 separating spaces (e.g.,
518 .BR intro (2)).
519 The preferred way to write this in the source file is:
520 .nf
521
522     .BR intro (2)
523
524 .fi
525 (Including the section number in cross references lets tools like
526 .BR man2html (1)
527 create properly hyperlinked pages.)
528 .SS Spelling
529 Starting with release 2.59,
530 .I man-pages
531 follows American spelling conventions;
532 please write all new pages and patches according to these conventions.
533 .SS Capitalization
534 In subsection ("SS") headings
535 capitalize the first word in heading, but otherwise use lower case,
536 except where English usage (e.g., proper nouns) or programming
537 language requirements (e.g., identifier names) dictate otherwise.
538 .SS Example programs and shell sessions
539 Manual pages can include example programs demonstrating how to
540 use a system call or library function.
541 However, note the following:
542 .TP 3
543 *
544 Example programs should be written in C.
545 .TP
546 *
547 An example program is necessary and useful only if it demonstrates
548 something beyond what can easily be provided in a textual
549 description of the interface.
550 An example program that does nothing
551 other than call an interface usually serves little purpose.
552 .TP
553 *
554 Example programs should be fairly short (preferably less than 100 lines;
555 ideally less than 50 lines).
556 .TP
557 *
558 Example programs should do error checking after system calls and
559 library function calls.
560 .TP
561 *
562 Example programs should be complete, and compile without
563 warnings when compiled with \fIcc\ \-Wall\fP.
564 .TP
565 *
566 Where possible and appropriate, example programs should allow
567 experimentation, by varying their behavior based on inputs
568 (ideally from command-line arguments, or alternatively, via
569 input read by the program).
570 .TP
571 *
572 Example programs should be laid out according to Kernighan and
573 Ritchie style, with 4-space indents.
574 (Avoid the use of TAB characters in source code!)
575 .PP
576 For some examples of what example programs should look like, see
577 .BR wait (2)
578 and
579 .BR pipe (2).
580
581 If you include a shell session demonstrating the use of a program
582 or other system feature, boldface the user input text,
583 to distinguish it from output produced by the system.
584 .SS Indentation of structure definitions, shell session logs, etc.
585 When structure definitions, shell session logs, and so on are included
586 in running text, indent them by 4 spaces (i.e., a block enclosed by
587 .I ".in\ +4n"
588 and
589 .IR ".in" ).
590 .SH EXAMPLE
591 For canonical examples of how man pages in the
592 .I man-pages
593 package should look, see
594 .BR pipe (2)
595 and
596 .BR fcntl (2).
597 .SH SEE ALSO
598 .BR man (1),
599 .BR man2html (1),
600 .BR groff (7),
601 .BR groff_man (7),
602 .BR man (7),
603 .BR mdoc (7)