xref: /openbsd-src/usr.bin/mandoc/man.1 (revision 594d0641eae63ecbd3f01e5ff289a5172138e005)
1.\" $OpenBSD: man.1,v 1.41 2025/01/26 14:43:05 schwarze Exp $
2.\"
3.\" Copyright (c) 1989, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\" Copyright (c) 2003, 2007, 2008, 2014 Jason McIntyre <jmc@openbsd.org>
6.\" Copyright (c) 2010, 2011, 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)man.1	8.2 (Berkeley) 1/2/94
33.\"
34.Dd $Mdocdate: January 26 2025 $
35.Dt MAN 1
36.Os
37.Sh NAME
38.Nm man
39.Nd display manual pages
40.Sh SYNOPSIS
41.Nm man
42.Op Fl acfhklw
43.Op Fl C Ar file
44.Op Fl M Ar path
45.Op Fl m Ar path
46.Op Fl S Ar subsection
47.Op Oo Fl s Oc Ar section
48.Ar name ...
49.Sh DESCRIPTION
50The
51.Nm
52utility
53displays the
54manual page entitled
55.Ar name .
56Pages may be selected according to
57a specific category
58.Pq Ar section
59or
60machine architecture
61.Pq Ar subsection ,
62or searched for with
63.Fl k
64using
65.Xr apropos 1
66search expressions.
67The default pager,
68.Xr less 1 ,
69supports the command
70.Ic :t
71to jump to definitions of specific terms (see
72.Dv MANPAGER ,
73below).
74.Pp
75The options are as follows:
76.Bl -tag -width Ds
77.It Fl a
78Display all matching manual pages.
79.It Fl C Ar file
80Use the specified
81.Ar file
82instead of the default configuration file.
83This permits users to configure their own manual environment.
84See
85.Xr man.conf 5
86for a description of the contents of this file.
87.It Fl c
88Copy the manual page to the standard output instead of using
89.Xr less 1
90to paginate it.
91This is done by default if the standard output is not a terminal device.
92.Pp
93When using
94.Fl c ,
95most terminal devices are unable to show the markup.
96To print the output of
97.Nm
98to the terminal with markup but without using a pager, pipe it to
99.Xr ul 1 .
100To remove the markup, pipe the output to
101.Xr col 1
102.Fl b
103instead.
104.It Fl f
105A synonym for
106.Xr whatis 1 .
107It searches for
108.Ar name
109in manual page names and displays the header lines from all matching pages.
110The search is case insensitive and matches whole words only.
111.It Fl h
112Display only the SYNOPSIS lines of the requested manual pages.
113Implies
114.Fl a
115and
116.Fl c .
117.It Fl k
118A synonym for
119.Xr apropos 1 .
120Instead of
121.Ar name ,
122an expression can be provided using the syntax described in the
123.Xr apropos 1
124manual.
125By default, it displays the header lines of all matching pages.
126.It Fl l
127A synonym for
128.Xr mandoc 1 .
129The
130.Ar name
131arguments are interpreted as filenames.
132No search is done and
133.Ar file ,
134.Ar path ,
135.Ar section ,
136.Ar subsection ,
137and
138.Fl w
139are ignored.
140This option implies
141.Fl a .
142.It Fl M Ar path
143Override the list of directories to search for manual pages.
144The supplied
145.Ar path
146must be a colon
147.Pq Ql \&:
148separated list of directories.
149This option also overrides the environment variable
150.Ev MANPATH
151and any directories specified in the
152.Xr man.conf 5
153file.
154.It Fl m Ar path
155Augment the list of directories to search for manual pages.
156The supplied
157.Ar path
158must be a colon
159.Pq Ql \&:
160separated list of directories.
161These directories will be searched before those specified using the
162.Fl M
163option, the
164.Ev MANPATH
165environment variable, the
166.Xr man.conf 5
167file, or the default directories.
168.It Fl S Ar subsection
169Only show pages for the specified
170.Xr machine 1
171architecture.
172.Ar subsection
173is case insensitive.
174.Pp
175By default manual pages for all architectures are installed.
176Therefore this option can be used to view pages for one
177architecture whilst using another.
178.Pp
179This option overrides the
180.Ev MACHINE
181environment variable.
182.Tg s
183.It Oo Fl s Oc Ar section
184Only select manuals from the specified
185.Ar section .
186The currently available sections are:
187.Pp
188.Bl -tag -width "localXXX" -offset indent -compact
189.It 1
190General commands
191.Pq tools and utilities .
192.It 2
193System calls and error numbers.
194.It 3
195Library functions.
196.It 3p
197.Xr perl 1
198programmer's reference guide.
199.It 4
200Device drivers.
201.It 5
202File formats.
203.It 6
204Games.
205.It 7
206Miscellaneous information.
207.It 8
208System maintenance and operation commands.
209.It 9
210Kernel internals.
211.El
212.It Fl w
213List the pathnames of all matching manual pages instead of displaying
214any of them.
215If no
216.Ar name
217is given, list the directories that would be searched.
218.El
219.Pp
220The options
221.Fl IKOTW
222are also supported and are documented in
223.Xr mandoc 1 .
224The options
225.Fl fkl
226are mutually exclusive and override each other.
227.Pp
228The search starts with the
229.Fl m
230argument if provided, then continues with the
231.Fl M
232argument, the
233.Ev MANPATH
234variable, the
235.Ic manpath
236entries in the
237.Xr man.conf 5
238file, or with
239.Pa /usr/share/man : Ns Pa /usr/X11R6/man : Ns Pa /usr/local/man
240by default.
241Within each of these, directories are searched in the order provided.
242Within each directory, the search proceeds according to the following
243list of sections: 1, 8, 6, 2, 3, 5, 7, 4, 9, 3p.
244The first match found is shown.
245.Pp
246The
247.Xr mandoc.db 5
248database is used for looking up manual page entries.
249In cases where the database is absent, outdated, or corrupt,
250.Nm
251falls back to looking for files called
252.Ar name . Ns Ar section .
253If both a formatted and an unformatted version of the same manual page,
254for example
255.Pa cat1/foo.0
256and
257.Pa man1/foo.1 ,
258exist in the same directory, only the unformatted version is used.
259The database is kept up to date with
260.Xr makewhatis 8 ,
261which is run by the
262.Xr weekly 8
263maintenance script.
264.Pp
265Guidelines for writing
266man pages can be found in
267.Xr mdoc 7 .
268.Sh ENVIRONMENT
269.Bl -tag -width MANPATHX
270.It Ev MACHINE
271As some manual pages are intended only for specific architectures,
272.Nm
273searches any subdirectories,
274with the same name as the current architecture,
275in every directory which it searches.
276Machine specific areas are checked before general areas.
277The current machine type may be overridden by setting the environment
278variable
279.Ev MACHINE
280to the name of a specific architecture,
281or with the
282.Fl S
283option.
284.Ev MACHINE
285is case insensitive.
286.It Ev MANPAGER
287Any non-empty value of the environment variable
288.Ev MANPAGER
289is used instead of the standard pagination program,
290.Xr less 1 .
291If
292.Xr less 1
293is used, the interactive
294.Ic :t
295command can be used to go to the definitions of various terms, for
296example command line options, command modifiers, internal commands,
297environment variables, function names, preprocessor macros,
298.Xr errno 2
299values, and some other emphasized words.
300Some terms may have defining text at more than one place.
301In that case, the
302.Xr less 1
303interactive commands
304.Ic t
305and
306.Ic T
307can be used to move to the next and to the previous place providing
308information about the term last searched for with
309.Ic :t .
310The
311.Fl O Cm tag Ns Op = Ns Ar term
312option documented in the
313.Xr mandoc 1
314manual opens a manual page at the definition of a specific
315.Ar term
316rather than at the beginning.
317.It Ev MANPATH
318Override the standard search path which is either specified in
319.Xr man.conf 5
320or the default path.
321The format of
322.Ev MANPATH
323is a colon
324.Pq Ql \&:
325separated list of directories.
326Invalid directories are ignored.
327Overridden by
328.Fl M ,
329ignored if
330.Fl l
331is specified.
332.Pp
333If
334.Ev MANPATH
335begins with a colon, it is appended to the standard path;
336if it ends with a colon, it is prepended to the standard path;
337or if it contains two adjacent colons,
338the standard path is inserted between the colons.
339.It Ev PAGER
340Specifies the pagination program to use when
341.Ev MANPAGER
342is not defined.
343If neither PAGER nor MANPAGER is defined,
344.Xr less 1
345is used.
346.El
347.Sh FILES
348.Bl -tag -width /etc/man.conf -compact
349.It Pa /etc/man.conf
350default
351.Nm
352configuration file
353.El
354.Sh EXIT STATUS
355.Ex -std man
356See
357.Xr mandoc 1
358for details.
359.Sh EXAMPLES
360Show all manual pages that mention the
361.Ev PWD
362environment variable:
363.Pp
364.Dl $ man -ak Ev=PWD
365.Pp
366Show the
367.Xr ksh 1
368manual and jump to the place where the
369.Ic pwd
370builtin command is described:
371.Pp
372.Dl $ man -O tag=pwd ksh
373.Pp
374Equivalently, use the command
375.Ql man ksh ,
376then type
377.Ql :tpwd
378and press the return key.
379.Pp
380Format a page for pasting extracts into an email message \(em
381avoid printing any UTF-8 characters, reduce the width to ease
382quoting in replies, and remove markup:
383.Pp
384.Dl $ man -T ascii -O width=65 pledge | col -b
385.Pp
386Read a typeset page in a PDF viewer:
387.Pp
388.Dl $ MANPAGER=mupdf man -T pdf lpd
389.Sh SEE ALSO
390.Xr apropos 1 ,
391.Xr col 1 ,
392.Xr mandoc 1 ,
393.Xr ul 1 ,
394.Xr whereis 1 ,
395.Xr man.conf 5 ,
396.Xr mdoc 7
397.Sh STANDARDS
398The
399.Nm
400utility is compliant with the
401.St -p1003.1-2008
402specification.
403.Pp
404The flags
405.Op Fl aCcfhIKlMmOSsTWw ,
406as well as the environment variables
407.Ev MACHINE ,
408.Ev MANPAGER ,
409and
410.Ev MANPATH ,
411are extensions to that specification.
412.Sh HISTORY
413A
414.Nm
415command first appeared in
416.At v2 .
417.Pp
418The
419.Fl w
420option first appeared in
421.At v7 ;
422.Fl f
423and
424.Fl k
425in
426.Pa /usr/usb/man
427in
428.Bx 4.0 ;
429.Fl M
430in
431.Bx 4.3 ;
432.Fl a
433in
434.Bx 4.3 Tahoe ;
435.Fl c
436and
437.Fl m
438in
439.Bx 4.3 Reno ;
440.Fl h
441in
442.Bx 4.3 Net/2 ;
443.Fl C
444in
445.Nx 1.0 ;
446.Fl s
447and
448.Fl S
449in
450.Ox 2.3 ;
451and
452.Fl I ,
453.Fl K ,
454.Fl l ,
455.Fl O ,
456and
457.Fl W
458in
459.Ox 5.7 .
460The
461.Fl T
462option first appeared in
463.At III
464and was also added in
465.Ox 5.7 .
466