apropos command in Linux with Examples
Linux/Unix comes with a huge number of commands and thus it become quite difficult sometimes to remember each and every command. apropos command becomes useful in such cases. apropos command helps the user when they don’t remember the exact command but knows a few keywords related to the command that define its uses or functionality. It searches the Linux man page with the help of the keyword provided by the user to find the command and its functions.
apropos [OPTION..] KEYWORD...
Example 1: Suppose you don’t know how to compress a file then you could type the following command in terminal and it will show all the related command and its short description or functionality.
After executing the above command you will observe a bunch of commands is listed on the terminal that deals with not only how to compress a file but also how to expand a compressed file, search a compressed file, comparing a compressed file etc.
Example 2: apropos also support multiple keywords if given as an argument i.e. we can also provide more than one keyword for a better search. Thus, if two keywords are provided the apropos command will display all the command’s list which contains either the first keyword in its man page description or the second keyword.
- Input 1 (With one keyword):
- Input 2 (With multiple keyword):
- -d: This option is used to emit debugging messages. When this option is used then terminal returns man directories, global path, path directory, warnings, etc. of each command which is related to the search keyword.
- -v: This option is used to print verbose warning messages.
- -e, –exact: This option is used to search each keyword for exact match. If no option is used, the apropos command returns list of all the command whose description in the man page description matches with the keyword or which are somehow related to the keyword given in the argument. However, when the -e option is used, the apropos only returns the command whose description exactly matches with the keyword.
- -w, –wildcard: This option is used when the keyword(s) contain wildcards. apropos will independently search the page name and the description matching against the keyword(s).
All the command related to sudo are listed when sudo is given as a wildcard.
- -a, –and: This option is used when we want all the keywords to match. It returns nothing if any one of the keywords supplied has no matching in the man page or description. In the below input, two keywords have been given and only two commands are displayed in the result since there is only one command that contains both the keyword.
- -l, –long: By default, the output is trimmed to the terminal width. This option becomes handy when we don’t want the result to be truncated.
- -C: This option is used when we don’t want to use the default(/manpath) but user configuration file.
- -L: Define the locale for this search.
- -m, –systems: This option use manual pages from other systems. This option is helpful when we want to search the man page description of other accessible operating system.
- -M, –manpath: Set search path for manual pages to PATH rather than the default $MANPATH.
- -s, –sections, –section: This option is used when we want to search only particular sections (colon-separated) that are given in the argument.
- -?, –help: This option displays the help list.
- -V, –version: Used to print program version.
- -r, –regex: This option interpret each keyword as a regex(regular expression). The keyword will be independently matched against the page name and description.
Please Login to comment...