man / info / help

Format and display help pages.

Syntax
      man [-adho] [-t | -w] [-M manpath] [-P pager] [-S mansect] [-m arch[:machine]] [-p [eprtv]] [mansect] page ...

      man -f [-d] [-M manpath] [-P pager] [-S mansect] keyword ...

      whatis [-d] [-s mansect] keyword ...

      man -k [-d] [-M manpath] [-P pager] [-S mansect] keyword ...

      apropos [-d] [-s mansect] keyword ...

Key:

   -M path Force a specific colon separated manual path instead of the default search path.
           See manpath(1).  Overrides the MANPATH environment variable.

   -P pager
                 Use specified pager.  Defaults to “less -sR” if color support is enabled, or “less -s”.
           Overrides the MANPAGER environment variable, which in turn overrides the PAGER environment variable.
    
   -S mansect
           Restricts manual sections searched to the specified colon delimited list.
           Defaults to “1:8:2:3:3lua:n:4:5:6:7:9:l”.  Overrides the MANSECT environment variable.

   -a      Display all manual pages instead of just the first found for each page argument.

   -d      Print extra debugging information. Repeat for increased verbosity. Does not display the manual page.

   -f      Emulate whatis(1). Note that only a subset of options will have any effect when man is invoked in
           this mode.  See the below description of whatis options for details.

   -h      Display short help message and exit.

   -k      Emulate apropos(1). Note that only a subset of options will have any effect when man is invoked in
           this mode.  See the below description of apropos options for details.
     
   -m arch[:machine]
           Overrid the default architecture and machine settings allowing lookup of other platform specific
           manual pages. This option is accepted, but not implemented, on macOS.

   -o      Force use of non-localized manual pages. See IMPLEMENTATION NOTES for how locale specific searches work.
           Overrides the LC_ALL, LC_CTYPE, and LANG environment variables.

   -p [eprtv]
           Use the list of given preprocessors before running nroff(1) or troff(1).
           Valid preprocessors arguments:

             e       eqn(1)
             p       pic(1)
             r       refer(1)
             t       tbl(1)
             v       vgrind(1)

           Overrides the MANROFFSEQ environment variable.
     
   -t      Send manual page source through troff(1) allowing transformation of the manual pages to other formats.

   -w      Display the location of the manual page instead of the contents of the manual page.

Options that apropos and whatis understand:

   -d      Same as the -d option for man.

   -s      Same as the -S option for man.

Press [Space bar] or [return] to view the next page.

Press [q] to exit.

Man displays help pages. If you specify mansect, man only looks in that section of the manual. name is normally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/) then man interprets it as a file specification, so that you can do man ./foo.5 or even man /cd/foo/bar.1.gz. See below for a description of where man looks for the manual page files.

When man is operated in apropos or whatis emulation mode, only a subset of its options will be honored. Specifically, -d, -M, -P, and -S have equivalent functionality in the apropos and whatis implementation provided. The MANPATH, MANSECT, and MANPAGER environment variables will similarly be honored.

The man utility finds and displays online manual documentation pages. If mansect is provided, man restricts the search to the specific section of the manual.

The sections of the manual are:
1. General Commands Manual
2. System Calls Manual
3. Library Functions Manual
4. Kernel Interfaces Manual
5. File Formats Manual
6. Games Manual
7. Miscellaneous Information Manual
8. System Manager's Manual
9. Kernel Developer's Manual

Internal commands

For simplicity, the windevcluster website includes both internal bash commands and external Unix commands in a single list. Many more commands are available and the man command will list the full details of these.

Internal means a command built into the shell, it’s the shell that performs the action.
External means the shell will fork and execute an external program as a new subprocess. External commands are available when running any shell.

For example, the cd command is built-in. The ls command, is external.

The man command lists all the internal commands for bash under: man bash

If you are running zsh then list all the internal commands with: man zshbuiltins

Implementation Notes

Locale Specific Searches
The man utility supports manual pages in different locales. The search behavior is dictated by the first of three environment variables with a nonempty string: LC_ALL, LC_CTYPE, or LANG.

If set, man will search for locale specific manual pages using the following logic:

lang_country.charset
lang.charset
en.charset

For example, if LC_ALL is set to “ja_JP.eucJP”, man will search the following paths when considering section 1 manual pages in /usr/share/man:

/usr/share/man/ja_JP.eucJP/man1
/usr/share/man/ja.eucJP/man1
/usr/share/man/en.eucJP/man1
/usr/share/man/man1

Search Path for Manual Pages

man uses a sophisticated method of finding manual page files, based on the invocation options and environment variables, the /etc/man.config configuration file, and some built in conventions and heuristics.

First, when the name argument to man contains a slash (/), man assumes it is a file specification itself, and there is no searching involved.

But in the normal case where name doesn’t contain a slash, man searches a variety of directories for a file that could be a manual page for the topic named.

If you specify the -M pathlist option, pathlist is a colon-separated list of the directories that man searches.

If you don’t specify --M but set the MANPATH environment variable, the value of that variable is the list of the directories that man searches.

If you don’t specify an explicit path list with -M or MANPATH, man develops its own path list based on the contents of the configuration file /etc/man.config. The MANPATH statements in the configuration file identify particular directories to include in the search path.

Furthermore, the MANPATH_MAP statements add to the search path depending on your command search path (i.e. your PATH environment variable). For each directory that may be in the command search path, a MANPATH_MAP statement specifies a directory that should be added to the search path for manual page files. man looks at the PATH variable and adds the corresponding directories to the manual page file search path. Thus, with the proper use of MANPATH_MAP, when you issue the command man xyz, you get a manual page for the program that would run if you issued the command xyz.

In addition, for each directory in the command search path (we’ll call it a "command directory") for which you do not have a MANPATH_MAP statement, man automatically looks for a manual page directory "nearby" namely as a subdirectory in the command directory itself or in the parent directory of the command directory.

You can disable the automatic "nearby" searches by including a NOAUTOPATH statement in /etc/man.config.

In each directory in the search path as described above, man searches for a file named topic.section, with an optional suffix on the section number and possibly a compression suffix. If it doesn’t find such a file, it then looks in any subdirectories named manN or catN where N is the manual section number. If the file is in a catN subdirectory, man assumes it is a formatted manual page file (cat page). Otherwise, man assumes it is unformatted. In either case, if the filename has a known compression suffix (like .gz), man assumes it is gzipped.

If you want to see where (or if) man would find the manual page for a particular topic, use the --path (-w) option.

Environment

The following environment variables affect the execution of man:

LC_ALL, LC_CTYPE, LANG
                Used to find locale specific manual pages.
                Valid values can be found by running the locale(1) command.  See IMPLEMENTATION NOTES for details.
                Influenced by the -o option.

MACHINE_ARCH, MACHINE
                Used to find platform specific manual pages.  If unset, the output of “sysctl hw.machine_arch” and
                “sysctl hw.machine” is used respectively.  See IMPLEMENTATION NOTES for details.
                Corresponds to the -m option.

MANPATH         The standard search path used by man(1) may be changed by specifying a path in the MANPATH
                environment variable.  Invalid paths, or paths without manual databases, are ignored.
                Overridden by -M.  If MANPATH begins with a colon, it is appended to the default list; if it
                ends with a colon, it is prepended to the default list; or if it contains two adjacent colons,
                the standard search path is inserted between the colons.
                If none of these conditions are met, it overrides the standard search path.

MANROFFSEQ      Used to determine the preprocessors for the manual source before running nroff(1) or troff(1).
                If unset, defaults to tbl(1).  Corresponds to the -p option.

MANSECT         Restricts manual sections searched to the specified colon delimited list.
                Corresponds to the -S option.

MANWIDTH        If set to a numeric value, used as the width manpages should be displayed.
                Otherwise, if set to a special value “tty”, and output is to a terminal, the pages may be
                displayed over the whole width of the screen.

MANCOLOR        If set, enables color support.

MANPAGER        Program used to display files.
                If unset, and color support is enabled, “less -sR” is used.
                If unset, and color support is disabled, then PAGER is used.  If that has no value either, “less -s” is used.

Files

/etc/man.conf   System configuration file.
/usr/local/etc/man.d/*.conf  Local configuration files.

Exit Status

The man utility exits 0 on success, and >0 if an error occurs.

Examples

Show the manual page for stat(2):

$ man 2 stat

Show all manual pages for ‘stat’.

$ man -a stat

List manual pages which match the regular expression either in the title or in the body:

$ man -k '\<copy\>.*archive'

Show the manual page for ls(1) and use cat(1) as pager:

$ man -P cat ls

Show the location of the ls(1) manual page:

$ man -w ls

To get a plain text version of a man page, without backspaces and underscores, try:

$ man foo | col -b > foo.mantxt

“Education is not the filling of a pail, but the lighting of a fire” ~ W. B. Yeats

Related macOS commands

Local man page: man - Command line help page on your local machine.
apropos - Search the whatis database for strings.
manpath(1)
whatis - Search the whatis database for complete words.
more - Display output one screen at a time.
less - Display output one screen at a time.


 
Copyright © 1999-2025 windevcluster.com
Some rights reserved