In Linux, when you ever need assistance concerning a command, all it’s essential to do is to open its man web page. However what if a scenario arises whereby the requirement is to shortly search the names and descriptions of all accessible man pages? Properly, Linux has bought your coated, as there exists a command dubbed apropos that does precisely this for you.
On this tutorial, we are going to focus on the fundamentals of apropos utilizing some simple to know examples. However earlier than we do this, it is value mentioning that each one examples right here have been examined on an Ubuntu 16.04 LTS machine.
The apropos command searches handbook web page names and descriptions for a user-supplied key phrase. Following is its syntax:
apropos [OPTIONS] key phrase …
And this is what the device’s man web page says about it:
Every handbook web page has a brief description accessible inside it. apropos
searches the descriptions for situations of key phrase.key phrase is normally an everyday expression, as if (-r) was used, or might
include wildcards (-w), or match the precise key phrase (-e). Utilizing these
choices, it might be essential to quote the key phrase or escape () the
particular characters to cease the shell from deciphering them.The usual matching guidelines enable matches to be made towards the web page
title and phrase boundaries within the description.The database searched by apropos is up to date by the mandb program.
Relying in your set up, this can be run by a periodic cron job,
or might want to be run manually after new handbook pages have been
put in.
Following are some Q&A-styled examples that ought to provide you with a good suggestion on how the apropos command works.
Q1. Learn how to use apropos?
Fundamental utilization is easy. Simply move the key phrase you need to search as enter to the apropos command.
For instance:
apropos dmesg
produced the next end result:
dmesg (1) - print or management the kernel ring buffer
After all, you possibly can move a number of key phrases as nicely.
For instance:
apropos dmesg whereis
Following is the output on this case:
dmesg (1) - print or management the kernel ring buffer
whereis (1) - find the binary, supply, and handbook web page recordsdata for a...
Q2. Learn how to make apropos seek for actual key phrases?
By default, the enter you move to the apropos command is not searched precisely. For instance, when you move ‘who’ as an enter, you will additionally see the device producing outcomes containing phrases like ‘whoami’.
So this is not a precise search. Nevertheless, you possibly can power apropos to seek for actual key phrases through the use of the -e or –exact command line choices.
So now you see that solely these entries that precisely match ‘who’ have been displayed within the output.
Q3. Learn how to make apropos show entries matching all key phrases?
In case you move a number of key phrases as enter to the apropos command, the device will output entries that match/include a minimum of one of many key phrases. Nevertheless, if you’d like apropos to supply solely these entries that match/include all key phrases, then use the -a command line choice.
For instance, this is the output of an apropos command with out the -a choice:
And this is the output with -a choice enabled:
This fall. Learn how to power apropos to not trim output?
As you’d have seen in output in earlier Q&As, the device trims entries if they’re too lengthy. For instance, see the highlighted line within the following output:
Nevertheless, if you’d like, you possibly can power apropos to supply full strains in output, one thing which you are able to do utilizing the -l command line choice.
Q5. Learn how to interpret apropos exit standing?
The apropos command produces 4 totally different exit standing: 0, 1, 2, and 16. Here is what every of those represents:
0 Profitable program execution.1 Utilization, syntax or configuration file error.
2 Operational error.
16 Nothing was discovered that matched the standards specified
Conclusion
Relying in your work profile, you may not require the apropos command on day by day foundation, however as you’d have understood by now, it could possibly be a lifesaver in sure conditions. We have mentioned some use command line choices right here. To know extra concerning the device, head to its man web page.
Comments