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