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