Posted on September 13, 2023 by nexonhost
How To Use Whatis Command.
The whatis command is used to get brief information about Linux commands or functions. It displays the manual page description in a single line of the command that passes with the whatis command. It searches for the strings that have been passed with it from its index databases. Its index database is maintained by the mandb program.
The whatis command selects a short description of the ‘NAME’ section in the manual page of the commands passed with it. It facilitates various command-line options to assist the user in getting a short description of the specified command.
Description
Each manual page has a short description available within it. whatis searches the manual page names and displays the manual page descriptions of any name matched.
name may contain wildcards (-w) or be a regular expression (-r). Using these options, it may be necessary to quote the name or escape (\) the special characters to stop the shell from interpreting them.
Index databases are used during the search and are updated by the mandb program. Depending on your installation, this may be run by a periodic cron job or may be run manually after new manual pages are installed. To produce an old style text whatis database from the relative index database, issue the command below:
whatis -M manpath -w '*' | sort > manpath/whatis
…where manpath is a manual page hierarchy such as /usr/man.
Syntax
whatis [-dlhvV] [-r|-w] [-s list] [-m system[,...]] [-M path] [-L locale] [-C file] name ...
Options
-d, –debug | Print debugging information. |
-v, –verbose | Print verbose warning messages. |
-r, –regex | Interpret each name as a regular expression. If a name matches any part of a page name, a match will be made. This option causes whatis to be somewhat slower due to the nature of database searches. |
-w, –wildcard | Interpret each name as a pattern containing shell style wildcards. For a match to be made, an expanded name must match the entire page name. This option causes whatis to be somewhat slower due to the nature of database searches. |
-l, –long | Do not trim output to the terminal width. Normally, output will be truncated to the terminal width to avoid ugly results from poorly-written NAME sections. |
-s list, –sections list, | Search only the given manual sections. The list is a colon-separated or comma-separated list of sections. If an entry in list is a simple section, for example “3“, then the displayed list of descriptions will include pages in sections “3“, “3perl“, “3x“, and so on; while if an entry in list has an extension, for example “3perl“, then the list only includes pages in that exact part of the manual section. |
-m system[,…], | If this system has access to other operating system’s manual page names, they can be accessed using this option. To search NewOS’s manual page names, use the option “-m NewOS“. The system specified is a combination of comma delimited operating system names. To include a search of the native operating system’s manual page names, include the system name man in the argument string. This option overrides the $SYSTEM environment variable. |
-M path, | Specify an alternate set of colon-delimited manual page hierarchies to search. By default, whatis uses the $MANPATH environment variable, unless it is empty or unset, in which case it will determine an appropriate manpath based on your $PATH environment variable. This option overrides the contents of $MANPATH. |
-L locale, | Whatis will normally determine your current locale by a call to the C function setlocale which interrogates 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 whatis. Note that it will not take effect until the search for pages actually begins. Output such as the help message always displays in the initially determined locale. |
-C file, –config-file=file | Use this user configuration file rather than the default of ~/.manpath. |
-h, –help | Print a help message and exit. |
-V, –version | Display version information. |
Exit status
0 | Successful program execution. |
1 | Usage, syntax or configuration file error. |
2 | Operational error. |
16 | Nothing was found that matched the criteria specified. |
Environment
SYSTEM | If $SYSTEM is set, it has the same effect as if it had been specified as the argument to the -m option. |
MANPATH | If $MANPATH is set, its value is interpreted as the colon-delimited manual page hierarchy search path to use. |
MANWIDTH | If $MANWIDTH is set, its value is used as the terminal width (see the –long option). If it is not set, the terminal width will be calculated using an ioctl if available, the value of $COLUMNS, or falling back to 80 charac |
Examples
whatis whatis
Display a description of what whatis is.