]>
Commit | Line | Data |
---|---|---|
ba83bc0d MK |
1 | .\" (C) Copyright 1992-1999 Rickard E. Faith and David A. Wheeler |
2 | .\" (faith@cs.unc.edu and dwheeler@ida.org) | |
c11b1abf | 3 | .\" and (C) Copyright 2007 Michael Kerrisk <mtk.manpages@gmail.com> |
ba83bc0d | 4 | .\" |
93015253 | 5 | .\" %%%LICENSE_START(VERBATIM) |
ba83bc0d MK |
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. | |
4b72fb64 | 25 | .\" %%%LICENSE_END |
988db661 MK |
26 | .\" |
27 | .\" 2007-05-30 created by mtk, using text from old man.7 plus | |
04bc8827 | 28 | .\" rewrites and additional text. |
ba83bc0d | 29 | .\" |
9ba01802 | 30 | .TH MAN-PAGES 7 2019-03-06 "Linux" "Linux Programmer's Manual" |
ba83bc0d MK |
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, | |
7aa48d58 MK |
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, | |
0b920015 MK |
43 | many of the pages that appear in Sections 3, 4, and 7, |
44 | and a few of the pages that appear in Sections 1, 5, and 8 | |
45 | of the man pages on a Linux system. | |
ba83bc0d MK |
46 | The conventions described on this page may also be useful |
47 | for authors writing man pages for other projects. | |
c634028a | 48 | .SS Sections of the manual pages |
ba83bc0d MK |
49 | .PP |
50 | The manual Sections are traditionally defined as follows: | |
ba83bc0d | 51 | .TP 10 |
db6642bd | 52 | .B 1 User commands (Programs) |
ba83bc0d MK |
53 | Those commands that can be executed by the user from within |
54 | a shell. | |
55 | .TP | |
56 | .B 2 System calls | |
db6642bd | 57 | Those functions which wrap operations performed by the kernel. |
ba83bc0d MK |
58 | .TP |
59 | .B 3 Library calls | |
db6642bd SA |
60 | All library functions excluding the system call wrappers |
61 | (Most of the | |
ba83bc0d | 62 | .I libc |
db6642bd | 63 | functions). |
ba83bc0d MK |
64 | .TP |
65 | .B 4 Special files (devices) | |
66 | Files found in | |
db6642bd SA |
67 | .I /dev |
68 | which allow to access to devices through the kernel. | |
ba83bc0d | 69 | .TP |
095f40d5 | 70 | .B 5 File formats and configuration files |
db6642bd | 71 | Describes various human-readable file formats and configuration files. |
ba83bc0d MK |
72 | .TP |
73 | .B 6 Games | |
db6642bd | 74 | Games and funny little programs available on the system. |
ba83bc0d | 75 | .TP |
d6aaae47 | 76 | .B 7 Overview, conventions, and miscellaneous |
db6642bd SA |
77 | Overviews or descriptions of various topics, conventions and protocols, |
78 | character set standards, the standard filesystem layout, and miscellaneous | |
79 | other things. | |
ba83bc0d MK |
80 | .TP |
81 | .B 8 System management commands | |
82 | Commands like | |
83 | .BR mount (8), | |
84 | many of which only root can execute. | |
85 | .\" .TP | |
86 | .\" .B 9 Kernel routines | |
87 | .\" This is an obsolete manual section. | |
88 | .\" Once it was thought a good idea to document the Linux kernel here, | |
89 | .\" but in fact very little has been documented, and the documentation | |
90 | .\" that exists is outdated already. | |
91 | .\" There are better sources of | |
92 | .\" information for kernel developers. | |
ba83bc0d MK |
93 | .SS Macro package |
94 | New manual pages should be marked up using the | |
add00eab | 95 | .B groff an.tmac |
ba83bc0d MK |
96 | package described in |
97 | .BR man (7). | |
988db661 | 98 | This choice is mainly for consistency: the vast majority of |
ba83bc0d MK |
99 | existing Linux manual pages are marked up using these macros. |
100 | .SS Conventions for source file layout | |
988db661 | 101 | Please limit source code line length to no more than about 75 characters |
ba83bc0d MK |
102 | wherever possible. |
103 | This helps avoid line-wrapping in some mail clients when patches are | |
104 | submitted inline. | |
5711c04f | 105 | .PP |
ba83bc0d MK |
106 | New sentences should be started on new lines. |
107 | This makes it easier to see the effect of patches, | |
108 | which often operate at the level of individual sentences. | |
109 | .SS Title line | |
aeb9b6a6 MK |
110 | The first command in a man page should be a |
111 | .B TH | |
112 | command: | |
6545cc56 | 113 | .PP |
ba83bc0d | 114 | .RS |
ba83bc0d | 115 | .B \&.TH |
0daa9e92 | 116 | .I "title section date source manual" |
ba83bc0d | 117 | .RE |
6545cc56 | 118 | .PP |
ba83bc0d MK |
119 | where: |
120 | .RS | |
121 | .TP 10 | |
122 | .I title | |
123 | The title of the man page, written in all caps (e.g., | |
124 | .IR MAN-PAGES ). | |
125 | .TP | |
126 | .I section | |
127 | The section number in which the man page should be placed (e.g., | |
128 | .IR 7 ). | |
129 | .TP | |
130 | .I date | |
1c4b22fb MK |
131 | The date of the last nontrivial change that was made to the man page. |
132 | (Within the | |
133 | .I man-pages | |
0094f2b0 | 134 | project, the necessary updates to these timestamps are handled |
1c4b22fb MK |
135 | automatically by scripts, so there is no need to manually update |
136 | them as part of a patch.) | |
ba83bc0d MK |
137 | Dates should be written in the form YYYY-MM-DD. |
138 | .TP | |
139 | .I source | |
140 | The source of the command, function, or system call. | |
5711c04f | 141 | .IP |
ba83bc0d MK |
142 | For those few \fIman-pages\fP pages in Sections 1 and 8, |
143 | probably you just want to write | |
144 | .IR GNU . | |
5711c04f | 145 | .IP |
ba83bc0d MK |
146 | For system calls, just write |
147 | .IR "Linux" . | |
148 | (An earlier practice was to write the version number | |
149 | of the kernel from which the manual page was being written/checked. | |
150 | However, this was never done consistently, and so was | |
151 | probably worse than including no version number. | |
152 | Henceforth, avoid including a version number.) | |
5711c04f | 153 | .IP |
988db661 | 154 | For library calls that are part of glibc or one of the |
ba83bc0d MK |
155 | other common GNU libraries, just use |
156 | .IR "GNU C Library" ", " GNU , | |
157 | or an empty string. | |
5711c04f | 158 | .IP |
ba83bc0d MK |
159 | For Section 4 pages, use |
160 | .IR "Linux" . | |
5711c04f | 161 | .IP |
ba83bc0d MK |
162 | In cases of doubt, just write |
163 | .IR Linux ", or " GNU . | |
164 | .TP | |
165 | .I manual | |
988db661 | 166 | The title of the manual (e.g., for Section 2 and 3 pages in |
ba83bc0d MK |
167 | the \fIman-pages\fP package, use |
168 | .IR "Linux Programmer's Manual" ). | |
169 | .RE | |
170 | .SS Sections within a manual page | |
171 | The list below shows conventional or suggested sections. | |
988db661 | 172 | Most manual pages should include at least the |
ba83bc0d MK |
173 | .B highlighted |
174 | sections. | |
04bc8827 | 175 | Arrange a new manual page so that sections |
ba83bc0d | 176 | are placed in the order shown in the list. |
9c40f2b9 MK |
177 | .PP |
178 | .in +4n | |
ba83bc0d | 179 | .nf |
ba83bc0d MK |
180 | \fBNAME\fP |
181 | \fBSYNOPSIS\fP | |
1f901dc4 | 182 | CONFIGURATION [Normally only in Section 4] |
ba83bc0d MK |
183 | \fBDESCRIPTION\fP |
184 | OPTIONS [Normally only in Sections 1, 8] | |
185 | EXIT STATUS [Normally only in Sections 1, 8] | |
186 | RETURN VALUE [Normally only in Sections 2, 3] | |
187 | .\" May 07: Few current man pages have an ERROR HANDLING section,,, | |
188 | .\" ERROR HANDLING, | |
189 | ERRORS [Typically only in Sections 2, 3] | |
190 | .\" May 07: Almost no current man pages have a USAGE section,,, | |
988db661 | 191 | .\" USAGE, |
25a46448 | 192 | .\" DIAGNOSTICS, |
ba83bc0d MK |
193 | .\" May 07: Almost no current man pages have a SECURITY section,,, |
194 | .\" SECURITY, | |
195 | ENVIRONMENT | |
196 | FILES | |
197 | VERSIONS [Normally only in Sections 2, 3] | |
a2dace6b | 198 | ATTRIBUTES [Normally only in Sections 2, 3] |
ba83bc0d MK |
199 | CONFORMING TO |
200 | NOTES | |
201 | BUGS | |
202 | EXAMPLE | |
dcbc136a MK |
203 | .\" AUTHORS sections are discouraged |
204 | .\" AUTHORS [Discouraged] | |
ba83bc0d | 205 | \fBSEE ALSO\fP |
9c40f2b9 | 206 | .fi |
ba83bc0d | 207 | .in |
e646a1ba | 208 | .PP |
ba83bc0d MK |
209 | .IR "Where a traditional heading would apply" ", " "please use it" ; |
210 | this kind of consistency can make the information easier to understand. | |
988db661 | 211 | If you must, you can create your own |
ba83bc0d MK |
212 | headings if they make things easier to understand (this can |
213 | be especially useful for pages in Sections 4 and 5). | |
214 | However, before doing this, consider whether you could use the | |
215 | traditional headings, with some subsections (\fI.SS\fP) within | |
216 | those sections. | |
5711c04f | 217 | .PP |
988db661 | 218 | The following list elaborates on the contents of each of |
ba83bc0d MK |
219 | the above sections. |
220 | .TP 14 | |
221 | .B NAME | |
222 | The name of this manual page. | |
5711c04f | 223 | .IP |
988db661 | 224 | See |
ba83bc0d MK |
225 | .BR man (7) |
226 | for important details of the line(s) that should follow the | |
25a46448 | 227 | \fB.SH NAME\fP command. |
472926d8 | 228 | All words in this line (including the word immediately |
d1a71985 | 229 | following the "\e\-") should be in lowercase, |
472926d8 MK |
230 | except where English or technical terminological convention |
231 | dictates otherwise. | |
ba83bc0d MK |
232 | .TP |
233 | .B SYNOPSIS | |
9042e249 | 234 | A brief summary of the command or function's interface. |
5711c04f | 235 | .IP |
ba83bc0d MK |
236 | For commands, this shows the syntax of the command and its arguments |
237 | (including options); | |
04bc8827 MK |
238 | boldface is used for as-is text and italics are used to |
239 | indicate replaceable arguments. | |
ba83bc0d MK |
240 | Brackets ([]) surround optional arguments, vertical bars (|) |
241 | separate choices, and ellipses (\&...) can be repeated. | |
242 | For functions, it shows any required data declarations or | |
243 | .B #include | |
244 | directives, followed by the function declaration. | |
5711c04f | 245 | .IP |
d0e676ff MK |
246 | Where a feature test macro must be defined in order to obtain |
247 | the declaration of a function (or a variable) from a header file, | |
248 | then the SYNOPSIS should indicate this, as described in | |
249 | .BR feature_test_macros (7). | |
e48efc84 | 250 | .\" FIXME . Say something here about compiler options |
ba83bc0d | 251 | .TP |
c9890844 MK |
252 | .B CONFIGURATION |
253 | Configuration details for a device. | |
5711c04f | 254 | .IP |
33a0ccb2 | 255 | This section normally appears only in Section 4 pages. |
c9890844 | 256 | .TP |
ba83bc0d | 257 | .B DESCRIPTION |
9042e249 | 258 | An explanation of what the program, function, or format does. |
5711c04f | 259 | .IP |
ba83bc0d MK |
260 | Discuss how it interacts with files and standard input, and what it |
261 | produces on standard output or standard error. | |
262 | Omit internals and implementation details unless they're critical for | |
263 | understanding the interface. | |
264 | Describe the usual case; | |
265 | for information on command-line options of a program use the | |
266 | .B OPTIONS | |
267 | section. | |
268 | .\" If there is some kind of input grammar or complex set of subcommands, | |
269 | .\" consider describing them in a separate | |
270 | .\" .B USAGE | |
271 | .\" section (and just place an overview in the | |
272 | .\" .B DESCRIPTION | |
273 | .\" section). | |
5711c04f | 274 | .IP |
3c4e1fb2 MK |
275 | When describing new behavior or new flags for |
276 | a system call or library function, | |
277 | be careful to note the kernel or C library version | |
278 | that introduced the change. | |
279 | The preferred method of noting this information for flags is as part of a | |
280 | .B .TP | |
281 | list, in the following form (here, for a new system call flag): | |
282 | .RS 22 | |
283 | .TP | |
284 | .BR XYZ_FLAG " (since Linux 3.7)" | |
285 | Description of flag... | |
286 | .RE | |
287 | .IP | |
3d1ee497 | 288 | Including version information is especially useful to users |
3c4e1fb2 MK |
289 | who are constrained to using older kernel or C library versions |
290 | (which is typical in embedded systems, for example). | |
ba83bc0d MK |
291 | .TP |
292 | .B OPTIONS | |
9042e249 | 293 | A description of the command-line options accepted by a |
ba83bc0d | 294 | program and how they change its behavior. |
5711c04f | 295 | .IP |
33a0ccb2 | 296 | This section should appear only for Section 1 and 8 manual pages. |
ba83bc0d MK |
297 | .\" .TP |
298 | .\" .B USAGE | |
299 | .\" describes the grammar of any sublanguage this implements. | |
ba83bc0d MK |
300 | .TP |
301 | .B EXIT STATUS | |
9042e249 | 302 | A list of the possible exit status values of a program and |
ba83bc0d | 303 | the conditions that cause these values to be returned. |
5711c04f | 304 | .IP |
33a0ccb2 | 305 | This section should appear only for Section 1 and 8 manual pages. |
ba83bc0d MK |
306 | .TP |
307 | .B RETURN VALUE | |
308 | For Section 2 and 3 pages, this section gives a | |
309 | list of the values the library routine will return to the caller | |
310 | and the conditions that cause these values to be returned. | |
311 | .TP | |
312 | .B ERRORS | |
313 | For Section 2 and 3 manual pages, this is a list of the | |
314 | values that may be placed in | |
315 | .I errno | |
316 | in the event of an error, along with information about the cause | |
317 | of the errors. | |
5711c04f | 318 | .IP |
520caa55 MK |
319 | Where several different conditions produce the same error, |
320 | the preferred approach is to create separate list entries | |
321 | (with duplicate error names) for each of the conditions. | |
322 | This makes the separate conditions clear, may make the list easier to read, | |
323 | and allows metainformation | |
324 | (e.g., kernel version number where the condition first became applicable) | |
325 | to be more easily marked for each condition. | |
5711c04f | 326 | .IP |
09f49246 | 327 | .IR "The error list should be in alphabetical order" . |
ba83bc0d MK |
328 | .TP |
329 | .B ENVIRONMENT | |
9042e249 | 330 | A list of all environment variables that affect the program or function |
ba83bc0d MK |
331 | and how they affect it. |
332 | .TP | |
333 | .B FILES | |
9042e249 | 334 | A list of the files the program or function uses, such as |
ba83bc0d MK |
335 | configuration files, startup files, |
336 | and files the program directly operates on. | |
5711c04f | 337 | .IP |
ba83bc0d MK |
338 | Give the full pathname of these files, and use the installation |
339 | process to modify the directory part to match user preferences. | |
340 | For many programs, the default installation location is in | |
341 | .IR /usr/local , | |
342 | so your base manual page should use | |
343 | .I /usr/local | |
344 | as the base. | |
345 | .\" May 07: Almost no current man pages have a DIAGNOSTICS section; | |
346 | .\" "RETURN VALUE" or "EXIT STATUS" is preferred. | |
347 | .\" .TP | |
348 | .\" .B DIAGNOSTICS | |
349 | .\" gives an overview of the most common error messages and how to | |
350 | .\" cope with them. | |
351 | .\" You don't need to explain system error messages | |
352 | .\" or fatal signals that can appear during execution of any program | |
353 | .\" unless they're special in some way to the program. | |
354 | .\" | |
355 | .\" May 07: Almost no current man pages have a SECURITY section. | |
356 | .\".TP | |
357 | .\".B SECURITY | |
358 | .\"discusses security issues and implications. | |
359 | .\"Warn about configurations or environments that should be avoided, | |
360 | .\"commands that may have security implications, and so on, especially | |
361 | .\"if they aren't obvious. | |
362 | .\"Discussing security in a separate section isn't necessary; | |
363 | .\"if it's easier to understand, place security information in the | |
364 | .\"other sections (such as the | |
365 | .\" .B DESCRIPTION | |
366 | .\" or | |
367 | .\" .B USAGE | |
368 | .\" section). | |
369 | .\" However, please include security information somewhere! | |
370 | .TP | |
746e0af1 | 371 | .B ATTRIBUTES |
361b7ac7 MK |
372 | A summary of various attributes of the function(s) documented on this page. |
373 | See | |
374 | .BR attributes (7) | |
375 | for further details. | |
746e0af1 | 376 | .TP |
ba83bc0d MK |
377 | .B VERSIONS |
378 | A brief summary of the Linux kernel or glibc versions where a | |
379 | system call or library function appeared, | |
380 | or changed significantly in its operation. | |
5711c04f | 381 | .IP |
294544e7 MK |
382 | As a general rule, every new interface should |
383 | include a VERSIONS section in its manual page. | |
384 | Unfortunately, | |
385 | many existing manual pages don't include this information | |
386 | (since there was no policy to do so when they were written). | |
387 | Patches to remedy this are welcome, | |
388 | but, from the perspective of programmers writing new code, | |
33a0ccb2 | 389 | this information probably matters only in the case of kernel |
294544e7 MK |
390 | interfaces that have been added in Linux 2.4 or later |
391 | (i.e., changes since kernel 2.2), | |
392 | and library functions that have been added to glibc since version 2.1 | |
393 | (i.e., changes since glibc 2.0). | |
5711c04f | 394 | .IP |
294544e7 MK |
395 | The |
396 | .BR syscalls (2) | |
f4b5a0b0 MK |
397 | manual page also provides information about kernel versions |
398 | in which various system calls first appeared. | |
ba83bc0d MK |
399 | .TP |
400 | .B CONFORMING TO | |
9042e249 | 401 | A description of any standards or conventions that relate to the function |
04bc8827 | 402 | or command described by the manual page. |
5711c04f | 403 | .IP |
7849287b MK |
404 | The preferred terms to use for the various standards are listed as |
405 | headings in | |
406 | .BR standards (7). | |
5711c04f | 407 | .IP |
04bc8827 MK |
408 | For a page in Section 2 or 3, |
409 | this section should note the POSIX.1 | |
410 | version(s) that the call conforms to, | |
411 | and also whether the call is specified in C99. | |
412 | (Don't worry too much about other standards like SUS, SUSv2, and XPG, | |
413 | or the SVr4 and 4.xBSD implementation standards, | |
414 | unless the call was specified in those standards, | |
415 | but isn't in the current version of POSIX.1.) | |
5711c04f | 416 | .IP |
988db661 MK |
417 | If the call is not governed by any standards but commonly |
418 | exists on other systems, note them. | |
8382f16d | 419 | If the call is Linux-specific, note this. |
5711c04f | 420 | .IP |
ebc2edd1 MK |
421 | If this section consists of just a list of standards |
422 | (which it commonly does), | |
423 | terminate the list with a period (\(aq.\(aq). | |
ba83bc0d MK |
424 | .TP |
425 | .B NOTES | |
9042e249 | 426 | Miscellaneous notes. |
5711c04f | 427 | .IP |
f8843c2e | 428 | For Section 2 and 3 man pages you may find it useful to include |
ba83bc0d | 429 | subsections (\fBSS\fP) named \fILinux Notes\fP and \fIGlibc Notes\fP. |
5711c04f | 430 | .IP |
3a8bef11 | 431 | In Section 2, use the heading |
0722a578 | 432 | .I "C library/kernel differences" |
3a8bef11 | 433 | to mark off notes that describe the differences (if any) between |
ef4f4031 | 434 | the C library wrapper function for a system call and |
3a8bef11 | 435 | the raw system call interface provided by the kernel. |
ba83bc0d MK |
436 | .TP |
437 | .B BUGS | |
9042e249 | 438 | A list of limitations, known defects or inconveniences, |
ba83bc0d MK |
439 | and other questionable activities. |
440 | .TP | |
441 | .B EXAMPLE | |
9042e249 | 442 | One or more examples demonstrating how this function, file or |
ba83bc0d | 443 | command is used. |
5711c04f | 444 | .IP |
04bc8827 MK |
445 | For details on writing example programs, |
446 | see \fIExample Programs\fP below. | |
ba83bc0d | 447 | .TP |
dcbc136a | 448 | .B AUTHORS |
9042e249 | 449 | A list of authors of the documentation or program. |
5711c04f | 450 | .IP |
dcbc136a | 451 | \fBUse of an AUTHORS section is strongly discouraged\fP. |
ba83bc0d MK |
452 | Generally, it is better not to clutter every page with a list |
453 | of (over time potentially numerous) authors; | |
454 | if you write or significantly amend a page, | |
455 | add a copyright notice as a comment in the source file. | |
0cc32b69 | 456 | If you are the author of a device driver and want to include |
f8843c2e | 457 | an address for reporting bugs, place this under the BUGS section. |
ba83bc0d MK |
458 | .TP |
459 | .B SEE ALSO | |
9042e249 | 460 | A comma-separated list of related man pages, possibly followed by |
ba83bc0d | 461 | other related pages or documents. |
5711c04f | 462 | .IP |
9042e249 | 463 | The list should be ordered by section number and |
2b917159 | 464 | then alphabetically by name. |
d2d136f7 | 465 | Do not terminate this list with a period. |
c92b6bb5 MK |
466 | .IP |
467 | Where the SEE ALSO list contains many long manual page names, | |
468 | to improve the visual result of the output, it may be useful to employ the | |
469 | .I .ad l | |
470 | (don't right justify) | |
471 | and | |
472 | .I .nh | |
97776844 | 473 | (don't hyphenate) |
c92b6bb5 | 474 | directives. |
4eaa04c5 | 475 | Hyphenation of individual page names can be prevented |
d1a71985 | 476 | by preceding words with the string "\e%". |
5711c04f | 477 | .IP |
aeb666ce MK |
478 | Given the distributed, autonomous nature of FOSS projects |
479 | and their documentation, it is sometimes necessary\(emand in many cases | |
480 | desirable\(emthat the SEE ALSO section includes references to | |
481 | manual pages provided by other projects. | |
7849287b | 482 | .SH STYLE GUIDE |
9730fd84 MK |
483 | The following subsections describe the preferred style for the |
484 | .IR man-pages | |
7849287b MK |
485 | project. |
486 | For details not covered below, the Chicago Manual of Style | |
9730fd84 MK |
487 | is usually a good source; |
488 | try also grepping for preexisting usage in the project source tree. | |
7849287b MK |
489 | .SS Use of gender-neutral language |
490 | As far as possible, use gender-neutral language in the text of man | |
aa89a58e | 491 | pages. |
7849287b | 492 | Use of "they" ("them", "themself", "their") as a gender-neutral singular |
9730fd84 | 493 | pronoun is acceptable. |
c0ada844 | 494 | .\" |
741abfa1 | 495 | .SS Formatting conventions for manual pages describing commands |
ba83bc0d | 496 | .PP |
741abfa1 | 497 | For manual pages that describe a command (typically in Sections 1 and 8), |
c0ada844 MK |
498 | the arguments are always specified using italics, |
499 | .IR "even in the SYNOPSIS section" . | |
5711c04f | 500 | .PP |
c0ada844 MK |
501 | The name of the command, and its options, should |
502 | always be formatted in bold. | |
503 | .\" | |
504 | .SS Formatting conventions for manual pages describing functions | |
505 | For manual pages that describe functions (typically in Sections 2 and 3), | |
506 | the arguments are always specified using italics, | |
ba83bc0d MK |
507 | .IR "even in the SYNOPSIS section" , |
508 | where the rest of the function is specified in bold: | |
509 | .PP | |
ba83bc0d | 510 | .BI " int myfunction(int " argc ", char **" argv ); |
ba83bc0d | 511 | .PP |
027ebd3c | 512 | Variable names should, like argument names, be specified in italics. |
5711c04f | 513 | .PP |
c0ada844 MK |
514 | Any reference to the subject of the current manual page |
515 | should be written with the name in bold followed by | |
516 | a pair of parentheses in Roman (normal) font. | |
517 | For example, in the | |
518 | .BR fcntl (2) | |
519 | man page, references to the subject of the page would be written as: | |
520 | .BR fcntl (). | |
521 | The preferred way to write this in the source file is: | |
9c40f2b9 MK |
522 | .PP |
523 | .EX | |
c0ada844 | 524 | .BR fcntl () |
9c40f2b9 MK |
525 | .EE |
526 | .PP | |
d1a71985 | 527 | (Using this format, rather than the use of "\efB...\efP()" |
c0ada844 MK |
528 | makes it easier to write tools that parse man page source files.) |
529 | .\" | |
530 | .SS Formatting conventions (general) | |
9730fd84 | 531 | Filenames (whether pathnames, or references to header files) |
fc573e5f MK |
532 | are always in italics (e.g., |
533 | .IR <stdio.h> ), | |
ba83bc0d MK |
534 | except in the SYNOPSIS section, where included files are in bold (e.g., |
535 | .BR "#include <stdio.h>" ). | |
9730fd84 | 536 | When referring to a standard header file include, |
f36234fa MK |
537 | specify the header file surrounded by angle brackets, |
538 | in the usual C way (e.g., | |
ab9616d3 | 539 | .IR <stdio.h> ). |
ba83bc0d | 540 | .PP |
efaef3da | 541 | Special macros, which are usually in uppercase, are in bold (e.g., |
ba83bc0d MK |
542 | .BR MAXINT ). |
543 | Exception: don't boldface NULL. | |
544 | .PP | |
545 | When enumerating a list of error codes, the codes are in bold (this list | |
546 | usually uses the | |
547 | .B \&.TP | |
548 | macro). | |
5711c04f | 549 | .PP |
027ebd3c | 550 | Complete commands should, if long, |
9730fd84 MK |
551 | be written as an indented line on their own, |
552 | with a blank line before and after the command, for example | |
e646a1ba | 553 | .PP |
027ebd3c | 554 | .in +4n |
e646a1ba | 555 | .EX |
027ebd3c | 556 | man 7 man-pages |
e646a1ba | 557 | .EE |
027ebd3c | 558 | .in |
e646a1ba | 559 | .PP |
a4f844c6 | 560 | If the command is short, then it can be included inline in the text, |
027ebd3c MK |
561 | in italic format, for example, |
562 | .IR "man 7 man-pages" . | |
24b74457 | 563 | In this case, it may be worth using nonbreaking spaces |
31a6818e | 564 | ("\e\ ") at suitable places in the command. |
10850212 MK |
565 | Command options should be written in italics (e.g., |
566 | .IR \-l ). | |
027ebd3c MK |
567 | .PP |
568 | Expressions, if not written on a separate indented line, should | |
569 | be specified in italics. | |
24b74457 | 570 | Again, the use of nonbreaking spaces may be appropriate |
027ebd3c | 571 | if the expression is inlined with normal text. |
5711c04f | 572 | .PP |
c0ada844 | 573 | When showing example shell sessions, user input should be formatted in bold, for example |
019d9ee8 | 574 | .PP |
c0ada844 | 575 | .in +4n |
019d9ee8 MK |
576 | .EX |
577 | $ \fBdate\fP | |
578 | Thu Jul 7 13:01:27 CEST 2016 | |
579 | .EE | |
c0ada844 | 580 | .in |
019d9ee8 | 581 | .PP |
ba83bc0d MK |
582 | .PP |
583 | Any reference to another man page | |
584 | should be written with the name in bold, | |
aeb9b6a6 MK |
585 | .I always |
586 | followed by the section number, | |
ba83bc0d MK |
587 | formatted in Roman (normal) font, without any |
588 | separating spaces (e.g., | |
589 | .BR intro (2)). | |
590 | The preferred way to write this in the source file is: | |
9c40f2b9 MK |
591 | .PP |
592 | .EX | |
ba83bc0d | 593 | .BR intro (2) |
9c40f2b9 MK |
594 | .EE |
595 | .PP | |
ba83bc0d MK |
596 | (Including the section number in cross references lets tools like |
597 | .BR man2html (1) | |
598 | create properly hyperlinked pages.) | |
5711c04f | 599 | .PP |
7849287b MK |
600 | Control characters should be written in bold face, |
601 | with no quotes; for example, | |
602 | .BR ^X . | |
55f7ee2a | 603 | .SS Spelling |
9daed026 | 604 | Starting with release 2.59, |
55f7ee2a | 605 | .I man-pages |
91e4f660 | 606 | follows American spelling conventions |
7849287b | 607 | (previously, there was a random mix of British and American spellings); |
55f7ee2a | 608 | please write all new pages and patches according to these conventions. |
5711c04f | 609 | .PP |
7849287b MK |
610 | Aside from the well-known spelling differences, |
611 | there are a few other subtleties to watch for: | |
612 | .IP * 3 | |
28aac7d7 | 613 | American English tends to use the forms "backward", "upward", "toward", |
7849287b | 614 | and so on |
28aac7d7 | 615 | rather than the British forms "backwards", "upwards", "towards", and so on. |
7849287b MK |
616 | .SS BSD version numbers |
617 | The classical scheme for writing BSD version numbers is | |
618 | .IR x.yBSD , | |
619 | where | |
620 | .I x.y | |
621 | is the version number (e.g., 4.2BSD). | |
622 | Avoid forms such as | |
623 | .IR "BSD 4.3" . | |
159f0403 | 624 | .SS Capitalization |
7849287b | 625 | In subsection ("SS") headings, |
efaef3da | 626 | capitalize the first word in the heading, but otherwise use lowercase, |
159f0403 MK |
627 | except where English usage (e.g., proper nouns) or programming |
628 | language requirements (e.g., identifier names) dictate otherwise. | |
09e311c5 | 629 | For example: |
5711c04f | 630 | .PP |
9c40f2b9 | 631 | .EX |
9730fd84 | 632 | .SS Unicode under Linux |
9c40f2b9 | 633 | .EE |
787dd4ad | 634 | .\" |
f78ed33a | 635 | .SS Indentation of structure definitions, shell session logs, and so on |
7849287b MK |
636 | When structure definitions, shell session logs, and so on are included |
637 | in running text, indent them by 4 spaces (i.e., a block enclosed by | |
638 | .I ".in\ +4n" | |
639 | and | |
d6dceb1a MK |
640 | .IR ".in" ), |
641 | format them using the | |
642 | .I .EX | |
643 | and | |
644 | .I EE | |
645 | macros, and surround them with suitable paragraph markers (either | |
646 | .I .PP | |
647 | or | |
648 | .IR .IP ). | |
649 | For example: | |
650 | .PP | |
651 | .in +4n | |
652 | .EX | |
653 | .PP | |
654 | .in +4n | |
655 | .EX | |
656 | int | |
657 | main(int argc, char *argv[]) | |
658 | { | |
659 | return 0; | |
660 | } | |
661 | .EE | |
662 | .in | |
663 | .PP | |
664 | .EE | |
665 | .in | |
7849287b MK |
666 | .SS Preferred terms |
667 | The following table lists some preferred terms to use in man pages, | |
668 | mainly to ensure consistency across pages. | |
7849287b MK |
669 | .TS |
670 | l l l | |
671 | --- | |
672 | l l l. | |
673 | Term Avoid using Notes | |
674 | ||
675 | bit mask bitmask | |
676 | built-in builtin | |
677 | Epoch epoch T{ | |
678 | For the UNIX Epoch (00:00:00, 1 Jan 1970 UTC) | |
679 | T} | |
680 | filename file name | |
9730fd84 | 681 | filesystem file system |
7849287b MK |
682 | hostname host name |
683 | inode i-node | |
a6ce0ba5 | 684 | lowercase lower case, lower-case |
777411ae | 685 | nonzero non-zero |
7849287b MK |
686 | pathname path name |
687 | pseudoterminal pseudo-terminal | |
688 | privileged port T{ | |
689 | reserved port, | |
690 | system port | |
691 | T} | |
692 | real-time T{ | |
693 | realtime, | |
4a6cd1db | 694 | real time |
7849287b MK |
695 | T} |
696 | run time runtime | |
697 | saved set-group-ID T{ | |
698 | saved group ID, | |
699 | saved set-GID | |
700 | T} | |
701 | saved set-user-ID T{ | |
702 | saved user ID, | |
703 | saved set-UID | |
704 | T} | |
705 | set-group-ID set-GID, setgid | |
706 | set-user-ID set-UID, setuid | |
707 | superuser T{ | |
708 | super user, | |
709 | super-user | |
710 | T} | |
644ee9c7 MK |
711 | superblock T{ |
712 | super block, | |
713 | super-block | |
714 | T} | |
7849287b MK |
715 | timestamp time stamp |
716 | timezone time zone | |
a6ce0ba5 | 717 | uppercase upper case, upper-case |
e03fae06 | 718 | usable useable |
7849287b MK |
719 | user space userspace |
720 | username user name | |
8d4b8846 MK |
721 | x86-64 x86_64 T{ |
722 | Except if referring to result of "uname\ \-m" or similar | |
723 | T} | |
7849287b MK |
724 | zeros zeroes |
725 | .TE | |
4a6cd1db DP |
726 | .PP |
727 | See also the discussion | |
9730fd84 MK |
728 | .IR "Hyphenation of attributive compounds" |
729 | below. | |
7849287b MK |
730 | .SS Terms to avoid |
731 | The following table lists some terms to avoid using in man pages, | |
732 | along with some suggested alternatives, | |
733 | mainly to ensure consistency across pages. | |
7849287b MK |
734 | .TS |
735 | l l l | |
736 | --- | |
737 | l l l. | |
738 | Avoid Use instead Notes | |
739 | ||
9730fd84 MK |
740 | 32bit 32-bit T{ |
741 | same for 8-bit, 16-bit, etc. | |
742 | T} | |
7849287b MK |
743 | current process calling process T{ |
744 | A common mistake made by kernel programmers when writing man pages | |
745 | T} | |
746 | manpage T{ | |
747 | man page, manual page | |
748 | T} | |
749 | minus infinity negative infinity | |
750 | non-root unprivileged user | |
751 | non-superuser unprivileged user | |
752 | nonprivileged unprivileged | |
753 | OS operating system | |
754 | plus infinity positive infinity | |
755 | pty pseudoterminal | |
7849287b MK |
756 | tty terminal |
757 | Unices UNIX systems | |
758 | Unixes UNIX systems | |
759 | .TE | |
7849287b | 760 | .SS Trademarks |
aa89a58e MK |
761 | Use the correct spelling and case for trademarks. |
762 | The following is a list of the correct spellings of various | |
7849287b | 763 | relevant trademarks that are sometimes misspelled: |
5711c04f | 764 | .PP |
7849287b MK |
765 | DG/UX |
766 | HP-UX | |
767 | UNIX | |
768 | UnixWare | |
769 | .SS NULL, NUL, null pointer, and null character | |
770 | A | |
771 | .IR "null pointer" | |
772 | is a pointer that points to nothing, | |
773 | and is normally indicated by the constant | |
774 | .IR NULL . | |
775 | On the other hand, | |
776 | .I NUL | |
777 | is the | |
778 | .IR "null byte", | |
779 | a byte with the value 0, represented in C via the character constant | |
780 | .IR \(aq\e0\(aq . | |
5711c04f | 781 | .PP |
7849287b MK |
782 | The preferred term for the pointer is "null pointer" or simply "NULL"; |
783 | avoid writing "NULL pointer". | |
5711c04f | 784 | .PP |
7849287b MK |
785 | The preferred term for the byte is "null byte". |
786 | Avoid writing "NUL", since it is too easily confused with "NULL". | |
787 | Avoid also the terms "zero byte" and "null character". | |
788 | The byte that terminates a C string should be described | |
789 | as "the terminating null byte"; | |
790 | strings may be described as "null-terminated", | |
791 | but avoid the use of "NUL-terminated". | |
792 | .SS Hyperlinks | |
793 | For hyperlinks, use the | |
794 | .IR .UR / .UE | |
795 | macro pair | |
796 | (see | |
797 | .BR groff_man (7)). | |
798 | This produces proper hyperlinks that can be used in a web browser, | |
799 | when rendering a page with, say: | |
5711c04f | 800 | .PP |
7849287b MK |
801 | BROWSER=firefox man -H pagename |
802 | .SS Use of e.g., i.e., etc., a.k.a., and similar | |
9ab7f611 BR |
803 | In general, the use of abbreviations such as "e.g.", "i.e.", "etc.", |
804 | "cf.", and "a.k.a." should be avoided, | |
805 | in favor of suitable full wordings | |
806 | ("for example", "that is", "compare to", "and so on", "also known as"). | |
5711c04f | 807 | .PP |
7849287b MK |
808 | The only place where such abbreviations may be acceptable is in |
809 | .I short | |
810 | parenthetical asides (e.g., like this one). | |
5711c04f | 811 | .PP |
7849287b MK |
812 | Always include periods in such abbreviations, as shown here. |
813 | In addition, "e.g." and "i.e." should always be followed by a comma. | |
814 | .SS Em-dashes | |
9730fd84 | 815 | The way to write an em-dash\(emthe glyph that appears |
d1a71985 | 816 | at either end of this subphrase\(emin *roff is with the macro "\e(em". |
9730fd84 MK |
817 | (On an ASCII terminal, an em-dash typically renders as two hyphens, |
818 | but in other typographical contexts it renders as a long dash.) | |
7849287b MK |
819 | Em-dashes should be written |
820 | .I without | |
821 | surrounding spaces. | |
822 | .SS Hyphenation of attributive compounds | |
aa89a58e | 823 | Compound terms should be hyphenated when used attributively |
4a6cd1db | 824 | (i.e., to qualify a following noun). Some examples: |
5711c04f | 825 | .PP |
9730fd84 | 826 | 32-bit value |
7849287b MK |
827 | command-line argument |
828 | floating-point number | |
829 | run-time check | |
830 | user-space function | |
831 | wide-character string | |
832 | .SS Hyphenation with multi, non, pre, re, sub, and so on | |
833 | The general tendency in modern English is not to hyphenate | |
834 | after prefixes such as "multi", "non", "pre", "re", "sub", and so on. | |
835 | Manual pages should generally follow this rule when these prefixes are | |
836 | used in natural English constructions with simple suffixes. | |
837 | The following list gives some examples of the preferred forms: | |
5711c04f | 838 | .PP |
7849287b MK |
839 | interprocess |
840 | multithreaded | |
841 | multiprocess | |
842 | nonblocking | |
843 | nondefault | |
844 | nonempty | |
845 | noninteractive | |
846 | nonnegative | |
847 | nonportable | |
848 | nonzero | |
849 | preallocated | |
850 | precreate | |
851 | prerecorded | |
852 | reestablished | |
853 | reinitialize | |
854 | rearm | |
855 | reread | |
856 | subcomponent | |
857 | subdirectory | |
858 | subsystem | |
5711c04f | 859 | .PP |
7849287b MK |
860 | Hyphens should be retained when the prefixes are used in nonstandard |
861 | English words, with trademarks, proper nouns, acronyms, or compound terms. | |
862 | Some examples: | |
5711c04f | 863 | .PP |
7849287b MK |
864 | non-ASCII |
865 | non-English | |
866 | non-NULL | |
867 | non-real-time | |
5711c04f | 868 | .PP |
7849287b MK |
869 | Finally, note that "re-create" and "recreate" are two different verbs, |
870 | and the former is probably what you want. | |
9f0e82b4 MK |
871 | .SS Real minus character |
872 | Where a real minus character is required (e.g., for numbers such as \-1, | |
e789e07c BR |
873 | for man page cross references such as |
874 | .BR utf\-8 (7), | |
9730fd84 MK |
875 | or when writing options that have a leading dash, such as in |
876 | .IR "ls\ \-l"), | |
4a6cd1db | 877 | use the following form in the man page source: |
5711c04f | 878 | .PP |
d1a71985 | 879 | \e\- |
5711c04f | 880 | .PP |
7849287b MK |
881 | This guideline applies also to code examples. |
882 | .SS Character constants | |
883 | To produce single quotes that render well in both ASCII and UTF-8, | |
884 | use the following form for character constants in the man page source: | |
5711c04f | 885 | .PP |
d1a71985 | 886 | \e(aqC\e(aq |
5711c04f | 887 | .PP |
7849287b MK |
888 | where |
889 | .I C | |
890 | is the quoted character. | |
891 | This guideline applies also to character constants used in code examples. | |
c634028a | 892 | .SS Example programs and shell sessions |
9730fd84 | 893 | Manual pages may include example programs demonstrating how to |
ba83bc0d MK |
894 | use a system call or library function. |
895 | However, note the following: | |
f78f2def | 896 | .IP * 3 |
ba83bc0d | 897 | Example programs should be written in C. |
f78f2def | 898 | .IP * |
33a0ccb2 | 899 | An example program is necessary and useful only if it demonstrates |
ba83bc0d MK |
900 | something beyond what can easily be provided in a textual |
901 | description of the interface. | |
902 | An example program that does nothing | |
903 | other than call an interface usually serves little purpose. | |
f78f2def | 904 | .IP * |
c04c44f8 MK |
905 | Example programs should be fairly short (preferably less than 100 lines; |
906 | ideally less than 50 lines). | |
f78f2def | 907 | .IP * |
ba83bc0d MK |
908 | Example programs should do error checking after system calls and |
909 | library function calls. | |
f78f2def | 910 | .IP * |
ba83bc0d | 911 | Example programs should be complete, and compile without |
5b8dbfd4 | 912 | warnings when compiled with \fIcc\ \-Wall\fP. |
f78f2def | 913 | .IP * |
ba83bc0d | 914 | Where possible and appropriate, example programs should allow |
d9bfdb9c | 915 | experimentation, by varying their behavior based on inputs |
ba83bc0d MK |
916 | (ideally from command-line arguments, or alternatively, via |
917 | input read by the program). | |
f78f2def | 918 | .IP * |
ba83bc0d | 919 | Example programs should be laid out according to Kernighan and |
5998eb25 | 920 | Ritchie style, with 4-space indents. |
ba83bc0d | 921 | (Avoid the use of TAB characters in source code!) |
b1f800c6 | 922 | The following command can be used to format your source code to |
d0b8a20c | 923 | something close to the preferred style: |
5711c04f | 924 | .IP |
d0b8a20c | 925 | indent \-npro \-kr \-i4 \-ts4 \-sob \-l72 \-ss \-nut \-psl prog.c |
f78f2def | 926 | .IP * |
4a6cd1db | 927 | For consistency, all example programs should terminate using either of: |
5711c04f | 928 | .IP |
7849287b MK |
929 | exit(EXIT_SUCCESS); |
930 | exit(EXIT_FAILURE); | |
5711c04f | 931 | .IP |
7849287b | 932 | Avoid using the following forms to terminate a program: |
5711c04f | 933 | .IP |
7849287b MK |
934 | exit(0); |
935 | exit(1); | |
936 | return n; | |
937 | .IP * | |
f78f2def MK |
938 | If there is extensive explanatory text before the |
939 | program source code, mark off the source code | |
d50ee7fb | 940 | with a subsection heading |
f78f2def MK |
941 | .IR "Program source" , |
942 | as in: | |
5711c04f | 943 | .IP |
f78f2def | 944 | .SS Program source |
5711c04f | 945 | .IP |
f78f2def MK |
946 | Always do this if the explanatory text includes a shell session log. |
947 | .PP | |
948 | If you include a shell session log demonstrating the use of a program | |
949 | or other system feature: | |
950 | .IP * 3 | |
951 | Place the session log above the source code listing | |
952 | .IP * | |
953 | Indent the session log by four spaces. | |
954 | .IP * | |
955 | Boldface the user input text, | |
956 | to distinguish it from output produced by the system. | |
ba83bc0d MK |
957 | .PP |
958 | For some examples of what example programs should look like, see | |
959 | .BR wait (2) | |
960 | and | |
961 | .BR pipe (2). | |
962 | .SH EXAMPLE | |
963 | For canonical examples of how man pages in the | |
0daa9e92 | 964 | .I man-pages |
ba83bc0d MK |
965 | package should look, see |
966 | .BR pipe (2) | |
967 | and | |
968 | .BR fcntl (2). | |
969 | .SH SEE ALSO | |
970 | .BR man (1), | |
971 | .BR man2html (1), | |
5e511b39 | 972 | .BR attributes (7), |
976093f0 MK |
973 | .BR groff (7), |
974 | .BR groff_man (7), | |
ba83bc0d MK |
975 | .BR man (7), |
976 | .BR mdoc (7) |