1MAN-PAGES(7)               Linux Programmer's Manual              MAN-PAGES(7)
2
3
4

NAME

6       man-pages - conventions for writing Linux man pages
7

SYNOPSIS

9       man [section] title
10

DESCRIPTION

12       This  page describes the conventions that should be employed when writ‐
13       ing man pages for the Linux  man-pages  project,  which  documents  the
14       user-space API provided by the Linux kernel and the GNU C library.  The
15       project thus provides most of the pages in Section 2, as well  as  many
16       of the pages that appear in Sections 3, 4, 5, and 7 of the man pages on
17       a Linux system.  The conventions described on this  page  may  also  be
18       useful for authors writing man pages for other projects.
19
20   Sections of the manual pages
21       The manual Sections are traditionally defined as follows:
22
23       1 Commands (Programs)
24                 Those commands that can be executed by the user from within a
25                 shell.
26
27       2 System calls
28                 Those functions which must be performed by the kernel.
29
30       3 Library calls
31                 Most of the libc functions.
32
33       4 Special files (devices)
34                 Files found in /dev.
35
36       5 File formats and conventions
37                 The format for /etc/passwd and other human-readable files.
38
39       6 Games
40
41       7 Overview, conventions, and miscellaneous
42                 Overviews of various topics, conventions and protocols, char‐
43                 acter set standards, and miscellaneous other things.
44
45       8 System management commands
46                 Commands like mount(8), many of which only root can execute.
47
48   Macro package
49       New  manual  pages  should be marked up using the groff an.tmac package
50       described in man(7).  This choice is mainly for consistency:  the  vast
51       majority  of  existing  Linux  manual  pages  are marked up using these
52       macros.
53
54   Conventions for source file layout
55       Please limit source code line length to no more than about  75  charac‐
56       ters  wherever  possible.   This helps avoid line-wrapping in some mail
57       clients when patches are submitted inline.
58
59       New sentences should be started on new lines.  This makes it easier  to
60       see the effect of patches, which often operate at the level of individ‐
61       ual sentences.
62
63   Title line
64       The first command in a man page should be a TH command:
65
66              .TH title section date source manual
67
68       where:
69
70              title     The title of the man page, written in all caps  (e.g.,
71                        MAN-PAGES).
72
73              section   The  section  number  in  which the man page should be
74                        placed (e.g., 7).
75
76              date      The date of the last revision—remember to change  this
77                        every  time  a  change  is made to the man page, since
78                        this is the most general way of doing version control.
79                        Dates should be written in the form YYYY-MM-DD.
80
81              source    The source of the command, function, or system call.
82
83                        For  those  few  man-pages  pages in Sections 1 and 8,
84                        probably you just want to write GNU.
85
86                        For system calls, just write Linux.  (An earlier prac‐
87                        tice  was  to  write  the version number of the kernel
88                        from which the manual page was being  written/checked.
89                        However,  this was never done consistently, and so was
90                        probably  worse  than  including  no  version  number.
91                        Henceforth, avoid including a version number.)
92
93                        For library calls that are part of glibc or one of the
94                        other common GNU libraries, just use  GNU  C  Library,
95                        GNU, or an empty string.
96
97                        For Section 4 pages, use Linux.
98
99                        In cases of doubt, just write Linux, or GNU.
100
101              manual    The  title  of  the  manual (e.g., for Section 2 and 3
102                        pages in the man-pages package, use Linux Programmer's
103                        Manual).
104
105   Sections within a manual page
106       The  list  below shows conventional or suggested sections.  Most manual
107       pages should include at least the highlighted sections.  Arrange a  new
108       manual page so that sections are placed in the order shown in the list.
109
110            NAME
111            SYNOPSIS
112            CONFIGURATION      [Normally only in Section 4]
113            DESCRIPTION
114            OPTIONS            [Normally only in Sections 1, 8]
115            EXIT STATUS        [Normally only in Sections 1, 8]
116            RETURN VALUE       [Normally only in Sections 2, 3]
117            ERRORS             [Typically only in Sections 2, 3]
118            ENVIRONMENT
119            FILES
120            ATTRIBUTES         [Normally only in Sections 2, 3]
121            VERSIONS           [Normally only in Sections 2, 3]
122            CONFORMING TO
123            NOTES
124            BUGS
125            EXAMPLE
126            SEE ALSO
127
128       Where  a  traditional  heading would apply, please use it; this kind of
129       consistency can make the information  easier  to  understand.   If  you
130       must,  you  can  create your own headings if they make things easier to
131       understand (this can be especially useful for pages in Sections  4  and
132       5).   However,  before  doing  this, consider whether you could use the
133       traditional headings, with some subsections  (.SS)  within  those  sec‐
134       tions.
135
136       The following list elaborates on the contents of each of the above sec‐
137       tions.
138
139       NAME          The name of this manual page.  See man(7)  for  important
140                     details  of  the  line(s) that should follow the .SH NAME
141                     command.  All words in  this  line  (including  the  word
142                     immediately  following  the "\-") should be in lowercase,
143                     except where English or technical terminological  conven‐
144                     tion dictates otherwise.
145
146       SYNOPSIS      briefly  describes  the  command or function's interface.
147                     For commands, this shows the syntax of  the  command  and
148                     its  arguments  (including options); boldface is used for
149                     as-is text and italics are used to  indicate  replaceable
150                     arguments.   Brackets  ([])  surround optional arguments,
151                     vertical bars (|) separate choices,  and  ellipses  (...)
152                     can  be  repeated.   For functions, it shows any required
153                     data declarations or #include directives, followed by the
154                     function declaration.
155
156                     Where  a  feature  test macro must be defined in order to
157                     obtain the declaration of a function (or a variable) from
158                     a header file, then the SYNOPSIS should indicate this, as
159                     described in feature_test_macros(7).
160
161       CONFIGURATION Configuration details for a device.   This  section  nor‐
162                     mally appears only in Section 4 pages.
163
164       DESCRIPTION   gives  an  explanation  of what the program, function, or
165                     format does.  Discuss how it  interacts  with  files  and
166                     standard  input,  and what it produces on standard output
167                     or standard error.   Omit  internals  and  implementation
168                     details  unless  they're  critical  for understanding the
169                     interface.  Describe the usual case; for  information  on
170                     command-line  options  of  a program use the OPTIONS sec‐
171                     tion.
172
173                     When describing new behavior or new flags  for  a  system
174                     call  or  library function, be careful to note the kernel
175                     or C library version that  introduced  the  change.   The
176                     preferred  method of noting this information for flags is
177                     as part of a .TP list, in the following form (here, for a
178                     new system call flag):
179
180                             XYZ_FLAG (since Linux 3.7)
181                                    Description of flag...
182
183                     Including  version  information  is  especially useful to
184                     users who are constrained to  using  older  kernel  or  C
185                     library  versions  (which is typical in embedded systems,
186                     for example).
187
188       OPTIONS       describes the command-line options accepted by a  program
189                     and  how  they  change its behavior.  This section should
190                     appear only for Section 1 and 8 manual pages.
191
192       EXIT STATUS   lists the possible exit status values of  a  program  and
193                     the  conditions  that  cause these values to be returned.
194                     This section should appear only for Section 1 and 8  man‐
195                     ual pages.
196
197       RETURN VALUE  For  Section  2 and 3 pages, this section gives a list of
198                     the values the library routine will return to the  caller
199                     and   the  conditions  that  cause  these  values  to  be
200                     returned.
201
202       ERRORS        For Section 2 and 3 manual pages, this is a list  of  the
203                     values  that  may  be  placed in errno in the event of an
204                     error, along with information  about  the  cause  of  the
205                     errors.  The error list should be in alphabetical order.
206
207       ENVIRONMENT   lists  all  environment variables that affect the program
208                     or function and how they affect it.
209
210       FILES         lists the files the program or  function  uses,  such  as
211                     configuration files, startup files, and files the program
212                     directly operates on.  Give the full  pathname  of  these
213                     files,  and  use  the  installation process to modify the
214                     directory part to match user preferences.  For many  pro‐
215                     grams,   the   default   installation   location   is  in
216                     /usr/local,  so  your  base  manual   page   should   use
217                     /usr/local as the base.
218
219       ATTRIBUTES    A  summary of various attributes of the function(s) docu‐
220                     mented on this page, broken into subsections.   The  fol‐
221                     lowing subsections are defined:
222
223
224                     Multithreading (see pthreads(7))
225                            This  subsection notes attributes relating to mul‐
226                            tithreaded applications:
227
228                            *  Whether the function is thread-safe.
229
230                            *  Whether the function is a cancellation point.
231
232                            *  Whether the function is async-cancel-safe.
233
234                            Details  of  these  attributes  can  be  found  in
235                            pthreads(7).
236
237       VERSIONS      A  brief  summary  of  the Linux kernel or glibc versions
238                     where a system call  or  library  function  appeared,  or
239                     changed  significantly  in  its  operation.  As a general
240                     rule, every new interface should include a VERSIONS  sec‐
241                     tion  in  its  manual page.  Unfortunately, many existing
242                     manual pages don't include this information (since  there
243                     was  no policy to do so when they were written).  Patches
244                     to remedy this are welcome, but, from the perspective  of
245                     programmers  writing  new code, this information probably
246                     matters only in the case of kernel interfaces  that  have
247                     been  added  in  Linux  2.4 or later (i.e., changes since
248                     kernel 2.2), and library functions that have  been  added
249                     to  glibc  since  version  2.1 (i.e., changes since glibc
250                     2.0).
251
252                     The syscalls(2) manual  page  also  provides  information
253                     about kernel versions in which various system calls first
254                     appeared.
255
256       CONFORMING TO describes any standards or conventions that relate to the
257                     function  or command described by the manual page.  For a
258                     page in Section 2 or 3,  this  section  should  note  the
259                     POSIX.1  version(s)  that  the call conforms to, and also
260                     whether the call is specified in C99.  (Don't  worry  too
261                     much  about  other standards like SUS, SUSv2, and XPG, or
262                     the SVr4 and 4.xBSD implementation standards, unless  the
263                     call  was  specified in those standards, but isn't in the
264                     current version of POSIX.1.)  (See standards(7).)
265
266                     If the call is not governed by any standards but commonly
267                     exists  on  other  systems,  note  them.   If the call is
268                     Linux-specific, note this.
269
270                     If this section consists of  just  a  list  of  standards
271                     (which  it  commonly  does),  terminate  the  list with a
272                     period ('.').
273
274       NOTES         provides miscellaneous notes.  For Section 2  and  3  man
275                     pages  you may find it useful to include subsections (SS)
276                     named Linux Notes and Glibc Notes.
277
278       BUGS          lists limitations, known defects or  inconveniences,  and
279                     other questionable activities.
280
281       EXAMPLE       provides  one  or more examples describing how this func‐
282                     tion, file or command is used.  For  details  on  writing
283                     example programs, see Example Programs below.
284
285       AUTHORS       lists authors of the documentation or program.  Use of an
286                     AUTHORS section is strongly discouraged.   Generally,  it
287                     is  better not to clutter every page with a list of (over
288                     time potentially numerous) authors; if you write or  sig‐
289                     nificantly amend a page, add a copyright notice as a com‐
290                     ment in the source file.  If you  are  the  author  of  a
291                     device  driver and want to include an address for report‐
292                     ing bugs, place this under the BUGS section.
293
294       SEE ALSO      provides a comma-separated list  of  related  man  pages,
295                     ordered  by  section  number  and  then alphabetically by
296                     name, possibly followed by other related pages  or  docu‐
297                     ments.  Do not terminate this with a period.
298
299                     Where  the  SEE  ALSO list contains many long manual page
300                     names, to improve the visual result of the output, it may
301                     be  useful  to employ the .ad l (don't right justify) and
302                     .nh (don't hyphenate) directives.  Hyphenation  of  indi‐
303                     vidual  page  names  can  be prevented by preceding words
304                     with the string "\%".
305
306   Font conventions
307       For functions, the arguments are always specified using  italics,  even
308       in the SYNOPSIS section, where the rest of the function is specified in
309       bold:
310
311           int myfunction(int argc, char **argv);
312
313       Variable names should, like argument names, be specified in italics.
314
315       Filenames  (whether  pathnames,  or  references   to   files   in   the
316       /usr/include directory) are always in italics (e.g., <stdio.h>), except
317       in the SYNOPSIS section,  where  included  files  are  in  bold  (e.g.,
318       #include  <stdio.h>).   When referring to a standard include file under
319       /usr/include, specify the header file surrounded by angle brackets,  in
320       the usual C way (e.g., <stdio.h>).
321
322       Special  macros,  which  are  usually in upper case, are in bold (e.g.,
323       MAXINT).  Exception: don't boldface NULL.
324
325       When enumerating a list of error codes, the codes  are  in  bold  (this
326       list usually uses the .TP macro).
327
328       Complete commands should, if long, be written as in an indented line on
329       their own, for example
330
331           man 7 man-pages
332
333       If the command is short, then it can be included inline in the text, in
334       italic  format,  for example, man 7 man-pages.  In this case, it may be
335       worth using nonbreaking spaces ("\ ") at suitable places  in  the  com‐
336       mand.  Command options should be written in italics, e.g., -l.
337
338       Expressions,  if  not  written  on  a separate indented line, should be
339       specified in italics.  Again, the use  of  nonbreaking  spaces  may  be
340       appropriate if the expression is inlined with normal text.
341
342       Any reference to the subject of the current manual page should be writ‐
343       ten with the name in bold.  If the subject is a function (i.e., this is
344       a  Section  2 or 3 page), then the name should be followed by a pair of
345       parentheses in Roman (normal) font.  For example, in the  fcntl(2)  man
346       page,  references  to  the  subject  of  the  page would be written as:
347       fcntl().  The preferred way to write this in the source file is:
348
349           .BR fcntl ()
350
351       (Using this format, rather than the use of "\fB...\fP()" makes it  eas‐
352       ier to write tools that parse man page source files.)
353
354       Any  reference  to  another man page should be written with the name in
355       bold, always followed by the section number, formatted in  Roman  (nor‐
356       mal)  font,  without  any separating spaces (e.g., intro(2)).  The pre‐
357       ferred way to write this in the source file is:
358
359           .BR intro (2)
360
361       (Including the section number  in  cross  references  lets  tools  like
362       man2html(1) create properly hyperlinked pages.)
363
364   Spelling
365       Starting with release 2.59, man-pages follows American spelling conven‐
366       tions; please write all new pages and patches according to  these  con‐
367       ventions.
368
369   Capitalization
370       In subsection ("SS") headings capitalize the first word in heading, but
371       otherwise use lower case, except  where  English  usage  (e.g.,  proper
372       nouns)  or  programming  language requirements (e.g., identifier names)
373       dictate otherwise.
374
375   Example programs and shell sessions
376       Manual pages can include example programs demonstrating how  to  use  a
377       system call or library function.  However, note the following:
378
379       *  Example programs should be written in C.
380
381       *  An  example  program is necessary and useful only if it demonstrates
382          something beyond what can easily be provided in a  textual  descrip‐
383          tion  of  the interface.  An example program that does nothing other
384          than call an interface usually serves little purpose.
385
386       *  Example programs should be fairly short (preferably  less  than  100
387          lines; ideally less than 50 lines).
388
389       *  Example  programs  should  do  error checking after system calls and
390          library function calls.
391
392       *  Example programs should be complete, and  compile  without  warnings
393          when compiled with cc -Wall.
394
395       *  Where possible and appropriate, example programs should allow exper‐
396          imentation, by varying their behavior based on inputs (ideally  from
397          command-line arguments, or alternatively, via input read by the pro‐
398          gram).
399
400       *  Example programs should be  laid  out  according  to  Kernighan  and
401          Ritchie  style, with 4-space indents.  (Avoid the use of TAB charac‐
402          ters in source code!)
403
404       For some examples of  what  example  programs  should  look  like,  see
405       wait(2) and pipe(2).
406
407       If  you  include  a shell session demonstrating the use of a program or
408       other system feature, boldface the user input text, to  distinguish  it
409       from output produced by the system.
410
411   Indentation of structure definitions, shell session logs, etc.
412       When  structure definitions, shell session logs, and so on are included
413       in running text, indent them by 4 spaces (i.e.,  a  block  enclosed  by
414       .in +4n and .in).
415

EXAMPLE

417       For canonical examples of how man pages in the man-pages package should
418       look, see pipe(2) and fcntl(2).
419

SEE ALSO

421       man(1), man2html(1), groff(7), groff_man(7), man(7), mdoc(7)
422

COLOPHON

424       This page is part of release 3.53 of the Linux  man-pages  project.   A
425       description  of  the project, and information about reporting bugs, can
426       be found at http://www.kernel.org/doc/man-pages/.
427
428
429
430Linux                             2013-07-24                      MAN-PAGES(7)
Impressum