Linux man command help and examples(What is, Concept and Definition)

On Linux and other Unix-like operating systems, man is the interface used to view the system reference manuals.

Description


man is the manual viewer of the system; It can be used to display man pages, scroll up and down, search for specific text occurrences, and other useful functions.


Each argument given to man is usually the name of a program, utility, or function.The man page associated with each of these arguments is found and displayed.A section number, if provided, it will instruct man to search only in that section of the manual.The default action is to search all available sections, following a predefined order and display only the first page found, even if the page exists in various sections.


Syntax

man [-C file ] [-d] [-D] [--warnings [= warnings ]] [-R encoding ] [-L locale ] [-m system [,...]] [-M path ] [-S list ] [-e extension ] [-i |-I] [--regex |--wildcard] [--names-only] [-a ] [-u] [--no-subpages] [-P locator ] [-r request ] [-7] [-E encoding ] [--no-hyphens] [--no-justification] [-p string ] [-t] [-T [ device ]] [-H [ browser ]] [-X [ ppp ]] [-Z] [[ section ] page ...]...man-k [ appropriate options ] regexp ...man-K [-w |-W] [-S list ] [-i |-I] [--regex] [ section ] term ...man-f [ options options ]...man-l [-C file ] [-d] [-D] [--warnings [=warnings]] [-R encoding] [-L locale ] [-P locator ] [-r request ] [-7] [-E encoding ] [-p string ] [-t] [-T [ device ]] [-H [ browser ]] [-X [ dpi ]] [-Z] file ...man-w |-W [-C file ] [-d] [-D] page ...man-c [-C file ] [-d] [-D] page ...man [-hV]

General Options














-h , --help Print a help message and exit.
-V , --version Show version information and exit.
-C file , --config-file= file Use the configuration file file instead of the default value of ~/.manpath .
-d , --debug Print debugging information.
-D , --default This option, when used, is normally specified as the first option; resets the behavior of man to its default value.Its use is to reset those options that may have been configured in $ MANOPT .Any option that follows -D will have its usual effect.
--warnings [= warnings ] Enable groff text formatter warnings.This can be used to perform sanity checks on the source text of the man pages.The warnings are a list of comma-separated warning names; if not provided, default is " mac ".See node " Warnings " on information page groff for a list of the available warning names.

Options: main modes of operation


















-f , --whatis Equivalent to the whatis command; displays a brief description of the man page, if available.
-k , --apropos Equivalent to the apropos command; Search the brief descriptions of the man pages for keywords and show matches.
-K , --global-apropos Searches for text on all pages of the manual.This option is a brute force search, and is likely to take a while; if you can, you should specify a section to reduce the number of pages to be searched.Search terms can be simple strings (the default) or regular expressions if the --regex option is used.
-l , --local-file Activate 'local' mode.Format and display local manual files instead of searching the system manual collection.Each manual page argument will be interpreted as a nroff source file in the correct format.No file produced cat.If a hyphen ('-') appears as one of the arguments, the input will be taken from stdin.When this option is not used, and man cannot find the required page, before displaying the error message, tries to act as if this option had been provided, using the name as the file name and looking for an exact match.
-w , -anywhere , --location Does not actually show manual pages; instead print the locations of the source nroff files that would be formatted.
-W , --where-cat , --location-cat Does not actually show manual pages, but prints the locations of the cat files that would be displayed.If -w and -W , print both, separated by a space.
-c , --catman This option is not for general use and should only be used by the catman program.
-R coding , --recode= coding Instead of formatting the man page in the usual way, send your converted font to the specified encoding.If you already know the encoding of the source file, you can also use manconv directly.However, This option allows you to convert multiple man pages to a single encoding without explicitly indicating the encoding for each, provided they are already installed in a structure similar to a hierarchy of man pages.

Options: Search for manual pages




























-L locale , --locale= locale man will normally determine your current location by calling the C setlocale function that checks the values ​​of various environment variables, possibly including $ LC_MESSAGES and $ LANG .To temporarily override the determined value, use this option to supply a locale string directly to man .Note that it will not take effect until start page search.Results like help message will always show in initially determined locale.
-m system [, ...], --systems= system [, ...] If this system has access to other operating system manual pages, they can be accessed using this option.To search for a manual page from (for example) the "NewOS" manual page collection, use the option -m NewOS .

The specified system can be a combination of comma-delimited operating system names.To include a search in the manual pages of the native operating system, include the system name man in the argument string.This option will override the environment variable $ SYSTEM .

-M path , --manpath= path Specify an alternative path to use.This option overrides the environment variable $ MANPATH and causes the -m option to be ignored.

A path specified as the path must be the root of a manual page hierarchy structure in sections as described in the man-db manual (in "The manual page system").To view manual pages outside such hierarchies, see option -l .

-S list , -s list , --sections= list The list is a colon or comma separated list of "order specific" sections of the manual to search for.This option overrides the $ MANSECT environment variable.(The spelling -s is for compatibility with System V.)
-e sub-extension , --extension= sub-extension Some systems incorporate large man page packages, such as those They accompany the Tcl package, in the main man page hierarchy.To avoid the problem of having two man pages with the same name, such as exit, the Tcl pages were generally assigned to the section l (lowercase L).However, it is now possible to put the pages in the correct section and assign them a specific "extension", in this case, exit (3tcl) .Under normal operation , man shows exit in preference to exit (3tcl) .To negotiate this situation and avoid having to know in which section the page you need resides , it is now possible to give man a sub-extension string indicating the page package.Using the example above, provide the -e tcl option to man will restrict the search to pages that have an extension of * tcl .
-i , --ignore-case Ignore uppercase and lowercase when searching for man pages.This option is the default.
-I , --match-case Search for man pages that are case sensitive.
--regex Show all pages with any part of their names or descriptions matching each page argument as a regular expression, as with apropos .As there is generally no reasonable way to choose a "best" "page when searching for a regular expression, this option implies -a .
--wildcard Show all pages with any part of their names or descriptions matching each page argument using shell-style wildcards, as with apropos-wildcard .The page argument must match with the full name or description, or match the word limits in the description.As there is generally no reasonable way to choose a "best" page when searching for a wildcard, this option implies -a .
--names-only If the --regex or --wildcard option is used, match only the page names, not the page descriptions, as with whatis.Otherwise, this option has no effect.
-a , --all By default, man will exit after displaying the most suitable manual page it finds.Using this option forces man to display all manual pages with names matching the search criteria.
-u , --update This option causes man to perform an inode-level consistency check on your database caches to ensure they are an accurate representation of the file system.It will only have a useful effect if man is installed with the setuid bitset.
--no-subpages By default, man will attempt to interpret the manual page name pairs listed on the command line as equivalent to a single manual page name containing either a hyphen or an underscore.This supports the common pattern of programs that implement multiple subcommands, allowing them to provide manual pages for each that can be accessed using a syntax similar to that used to invoke subcommands, for example, the command: man-aw git diff displays the man page:/usr/share/man/man1/git-diff.1.gz To disable this behavior, use the --no-subpages option.

For example:

man-aw-no-subpages git diff will show the man pages for both git and diff :/usr/share/man/man1/git.1.gz/usr/share/man/man3/Git.3pm.gz/usr/share/man/man1/diff.1.gz

Options: Formatted output control























-P locator , --pager= pager Specify which output locator to use.By default, man uses pager-s .This option overrides the environment variable $ MANPAGER , which in turn overrides the $ PAGER environment variable.Not used in conjunction with -f or -k .

The value can be a single command name or command with arguments, and you can use shell quotes (backslashes, single quotes, or double quotes).don't use pipes to connect multiple commands; if you need to, use a container script, which can take the file to display as an argument or as standard input.

-r request , --prompt= request If a recent version of less is used as a locator, man will try to set your request and some reasonable options.The default flag looks like this: Manual page name (sec.) Line x...where name indicates the name of the manual page, sec denotes the section found below and x of the current line number.This is accomplished by using environment variable $ LESS .

Providing -r a string will override this default value.The string can contain the text $ MAN_PN which will expand to the name of the current manual page and its section name surrounded by " (" and ") ".The string used to producing the default value could be expressed as

\ Manual \ page \ \ $ MAN_PN \? Ltline \% lt? L/% L.: Byte \% bB? H.H..? \ (END) :? pB \% pB \\%..(press h for help or q to exit) Here it is divided into three lines only for readability reasons.For its meaning, see the manual for less.

The request string first is evaluated by the shell.All double quotes, back quotes and backslashes in the request must be escaped by a backslash.The request string can end in an escaped $ which can be followed by other options for less .By default, man sets the options -ix8 .

If you want to completely override the request string processing for man , use the environment variable $ MANLESS described below.

-7 , --ascii

When displaying a pure ASCII man page on a terminal or 7-bit terminal emulator, some characters may not display correctly when using the latin1 device description with GNU nroff.This option allows pure ASCII manpages to be displayed in ASCII with the latin1 device.It will not translate any latin1 text.The following table shows the translations made: some parts only can display correctly when using GNU latin1 nroff .


description octal latin1 ASCII
continuation script 255 --
bullet (midpoint) 267 · or
acute accent 264 ´ '
multiplication sign 327 × x

This table is included in the man man page.If these characters are seen inside your terminal and the latin1 column is displayed correctly, your terminal may be configured for latin1 and this option is not necessary.If the columns latin1 and ASCII are identical, then you are viewing the manual page man using this option or man did not format this page using device description latin1 for some reason.If column latin1 is missing or corrupted , you may need to view manual pages with this option specified.

This option is ignored when using the -t , -H , -options.T or -Z and may be useless for versions of nroff other than GNU.

-E coding , --coding= coding Generate output for non-default character encoding.For backward compatibility, encoding can be a nroff device such as ascii , latin1 or utf8 , as well as true character encoding like UTF-8 . --no-hyphens , --nh Normally, nroff will automatically separate text in line breaks even in words that do not contain hyphens, if necessary to place the words on a line without excessive space.This option disables syllabic separation.Automatic, so words will only be hyphenated if they already contain hyphens.

If you are writing a man page and want to prevent nroff from separating a word at an inappropriate point, do not use this option, but see the nroff documentation instead; for example, you can put " \% " inside a word to indicate that it can be hyphenated at that point, or put " \% " at the beginning of a word to prevent it from being separated by hyphens.

--no justification , --nj Normally nroff will automatically justify text in both margins.This option disables full justification, leaving it justified only in the left margin, sometimes called "unequal-right" text.

If you are typing a man page and you want to avoid nroff justifying certain paragraphs, don't use this option, but check the nroff documentation instead; for example, you can use ".na ", ".nf ", ".fi " and ".ad "requests to temporarily disable wrapping and padding.

-p string , --processor= string Specify the sequence of preprocessors that will run before nroff or troff / groff .Not all installations will have a full set of preprocessors.Some of the preprocessors and the letters used to designate them are: eqn ( e ), grap ( g ), pic ( p ), tbl ( t ), vgrind ( v ), see ( r ).This option overrides the environment variable $ MANROFFSEQ . zsoelim always runs as the first preprocessor. -t , --troff Use groff-mando to format the man page to standard output.This option is not required in conjunction with -H , -T or -Z . -T [ device ], --troff-device [= device ] This option is used to change the output of groff (or possibly troff ) to be suitable for a device other than the default.It implies -t .Examples include dvi , latin1 , ps , utf8 , X75 and X100 . -H [ browser ], --html [= browser ] This option will cause groff to produce HTML results and display them in a web browser.Your choice of browser is determined by the optional browser argument if one is provided, by the environment variable $ BROWSER , or by a default compile time if that's not set (usually lynx).This option implies -t , and will only work with GNU troff . -X [ dpi ], --gxditview [= dpi ] This option displays the result of groff in a graphics window using the gxditview program.The ppp (dots per inch) can be 75 , 75-12 , 100 or 100-12 , default to 75 ; Variants -12 use a 12-point base font.This option implies -T with the X75, X75-12, X100 or X100-12 device, respectively. -Z , --ditroff groff will run troff and then use an appropriate post processor to produce a suitable output for the chosen device.If groff-mandc is groff , this option is passed to groff and will suppress the use of a post processor.It implies -t .

Section numbers


The section numbers in the manual are listed below.As you read the documentation, if you see a command name followed by a number in parentheses, the number refers to one of these sections.For example, man is the documentation for man found in section number 1 .Some commands may have documentation in more than one section, so the numbers after the name The command can direct you to the correct section to find a specific type of information.


The section numbers and topics they cover are as follows:


section # topic 1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev )
5 File formats and conventions, eg /etc/passwd
6 Games
7 Various (including macro and convention packages), for example man , groff
8 System administration commands (generally only for root)
9 Core routines [Non-standard]

Exit status


When finished, man will return one of the following exit states:












0 Returned after successful program execution.
1 Returned if there was a usage, syntax, or configuration file error.
2 Returned if there was an operational error.
3 Returned if a child process returned a non-zero exit status.
16 Returns if one or more of the searched pages, files or keywords did not exist or did not match.

Environment


man uses the following environment variables:




























MANPATH If $ MANPATH is set, its value is used as the path to search for manual pages.
MANROFFOPT The content of $ MANROFFOPT is added to the command line every time man invokes the formatter (nroff, troff, or groff ).
MANROFFSEQ If $ MANROFFSEQ is set, its value is used to determine the set of preprocessors to go through each man page.The default preprocessor list is system dependent.
MANSECT If $ MANSECT is set, its value is a colon-delimited list of sections and is used to determine which manual sections to search for and in which order.
MANPAGER , PAGER If $ MANPAGER or $ PAGER is set ( $ MANPAGER is used preferably), its value is used as the name of the program used to display the man page.By default pager-s is used.

The value can be a simple command name or a command with arguments, and you can use shell quotes ( backslashes, single quotes or double quotes).You may not use pipes to connect multiple commands; if you need to, use a container script, which can take the file to display as an argument or as standard input.

NO MAN If $ MANLESS is set, man will not perform any of its usual processes to configure a request string for the minus pager.Instead, the value of $ MANLESS will be copied verbatim to $ LESS .For example, if you want to unconditionally set the request string to "my request string", set $ MANLESS to '-Psmy request string '.
BROWSER If $ BROWSER is set, its value is a list of colon-delimited commands, each of which is used to try to start a web browser for man-html .In each command, % s is replaced by a file name that contains the HTML output of groff , %% is replaced with a single percent sign (% ), and % c is replaced by a colon (: ).
SYSTEM If $ SYSTEM is set, it will have the same effect as if it had been specified as an argument for the -m option.
MANOPT If $ MANOPT is set, it will be parsed before the man command line and expected to have a similar format.Like all other specific environment variables of man can be expressed as command line options and therefore are candidates for inclusion in $ MANOPT , they are expected to become obsolete.Note: all spaces to be interpreted as part An option argument must be escaped (preceded by a backslash).
MANWIDTH If $ MANWIDTH is set, its value is used as the length of the line for which the manual pages should be formatted.If not configured, the manual pages will be formatted with a line length appropriate for the current terminal (using a ioctl if available, the value of $ COLUMNS , or rewinding up to 80 characters if none are available). cat pages will only be saved when the default format can be used, that is, when the Terminal line length is between 66 and 80 characters.
MAN_KEEP_FORMATTING Normally, when the output is not directed to a terminal (such as a file or a pipe), format characters are discarded to make the result easier to read without special tools, however if $ MAN_KEEP_FORMATTING is set to any non-empty value, these formatting characters are preserved.This can be useful for wrappers around man that can interpret formatting characters.
MAN_KEEP_STDERR Typically, when the output is directed to a terminal (usually a pager), any error output from the command used to produce formatted versions of manual pages is discarded to avoid interfering with the pager display.Programs like groff often produce relatively minor error messages about typographical issues like misalignment, which are unpleasant and generally confusing when displayed alongside the man page.However, you may want to see them anyway, so if $ MAN_KEEP_STDERR is set to any non-empty value, the error output will show as usual.
LANG , LC_MESSAGES Depending on the system and implementation, one or both of $ LANG and $ LC_MESSAGES will be interrogated for the current location of the message. man will display your messages in that locale (if available).

Files


The following files are used by man :










/etc/manpath.config The configuration file man-db .
/usr/share/man A global manual page hierarchy.
/usr/share/man/index. ( bt | db | dir | pag ) A traditional global index database cache.
/var/cache/man/index. ( bt | db | dir | pag ) An FHS compliant global index database cache.

Examples

man man

See the man page for the man command.

man-nh-nj man

See the man page for man , no hyphenated words or lines.

apropos -Search the man pages for a word key or regular expression. info -Reads information documents. whatis -Displays short descriptions of manual pages.

Comments