{"id":5371,"date":"2018-07-12T20:04:14","date_gmt":"2018-07-12T16:04:14","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-apropos-command\/"},"modified":"2018-07-12T20:04:14","modified_gmt":"2018-07-12T16:04:14","slug":"linux-apropos-command-tutorial-for-beginners-5-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-apropos-command-tutorial-for-beginners-5-examples\/","title":{"rendered":"Linux apropos Command Tutorial for Beginners (5 Examples)"},"content":{"rendered":"<p>In Linux, if you ever need help regarding a command, all you need to do is to open its man page. But what if a situation arises wherein the requirement is\u00a0to quickly search the names and descriptions of all available man pages? Well, Linux has got your covered, as there exists a command dubbed <strong>apropos<\/strong> that does exactly this for you.<\/p>\n<p>In this tutorial, we will discuss the basics of apropos using some easy to understand examples. But before we do that, it&#8217;s worth mentioning that all examples here have been tested on an Ubuntu 16.04 LTS machine.<\/p>\n<p>The apropos command searches manual page names and descriptions for a user-supplied keyword. Following is its syntax:<\/p>\n<p class=\"command\">apropos [OPTIONS] keyword &#8230;<\/p>\n<p>And here&#8217;s what the tool&#8217;s man page says about it:<\/p>\n<pre readability=\"21\"> Each manual page has a short description available within it.\u00a0\u00a0 apropos<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 searches the descriptions for instances of keyword.<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 keyword\u00a0 is\u00a0 usually\u00a0 a regular expression, as if (-r) was used, or may<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 contain wildcards (-w), or match the exact keyword (-e).\u00a0\u00a0 Using\u00a0 these<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 options,\u00a0 it\u00a0 may\u00a0 be\u00a0 necessary to quote the keyword or escape (\\) the<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 special characters to stop the shell from interpreting them.<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The standard matching rules allow matches to be made against\u00a0 the\u00a0 page<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 name and word boundaries in the description.<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The\u00a0 database\u00a0 searched\u00a0 by\u00a0 apropos\u00a0 is\u00a0 updated by the mandb program.<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Depending on your installation, this may be run by a periodic cron job,<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 or\u00a0 may\u00a0 need\u00a0 to\u00a0 be\u00a0 run\u00a0 manually\u00a0 after\u00a0 new manual pages have been<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 installed.<\/p><\/pre>\n<p>Following are some Q&amp;A-styled examples that should give you a good idea on how the apropos command works.<\/p>\n<h2 id=\"q-how-to-use-apropos\">Q1. How to use apropos?<\/h2>\n<p>Basic usage is simple. Just pass the keyword you want to search as input to the apropos command.<\/p>\n<p>For example:<\/p>\n<p class=\"command\">apropos dmesg<\/p>\n<p>produced the following result:<\/p>\n<pre>dmesg (1)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 - print or control the kernel ring buffer<\/pre>\n<p>Of course, you can pass multiple keywords as well.<\/p>\n<p>For example:<\/p>\n<p class=\"command\">apropos dmesg whereis<\/p>\n<p>Following is the output in this case:<\/p>\n<pre>dmesg (1)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 - print or control the kernel ring buffer<br\/>whereis (1)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 - locate the binary, source, and manual page files for a...<\/pre>\n<h2 id=\"q-how-to-make-apropos-search-for-exact-keywords\">Q2. How to make apropos search for exact keywords?<\/h2>\n<p>By default, the input you pass to the apropos command isn&#8217;t searched exactly. For example, if you pass &#8216;who&#8217; as an input, you&#8217;ll also see the tool producing results containing words like &#8216;whoami&#8217;.<\/p>\n<p><a class=\"fancybox\" id=\"img-apropos-exact-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/apropos-exact-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples.png\" alt=\"How to make apropos search for exact keywords\" width=\"500\" height=\"97\" title=\"\"><\/a><\/p>\n<p>So this isn&#8217;t an exact search. However, you can force apropos to search for exact keywords by using the -e or &#8211;exact command line options.<\/p>\n<p><a class=\"fancybox\" id=\"img-apropos-e-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/apropos-e-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-1.png\" alt=\"apropos exact search\" width=\"500\" height=\"83\" title=\"\"><\/a><\/p>\n<p>So now you see that only those entries that exactly match &#8216;who&#8217; were displayed in the output.<\/p>\n<h2 id=\"q-how-to-make-apropos-display-entries-matching-all-keywords\">Q3. How to make apropos display entries matching all keywords?<\/h2>\n<p>If you pass multiple keywords as input to the apropos command, the tool will output entries that match\/contain at least one of the keywords. However, if you want apropos to produce only those entries that match\/contain all keywords, then use the -a command line option.<\/p>\n<p>For example, here&#8217;s the output of an apropos command without the -a option:<\/p>\n<p><a class=\"fancybox\" id=\"img-apropos-a-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/apropos-a-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-2.png\" alt=\"How to make apropos display entries matching all keywords\" width=\"500\" height=\"276\" title=\"\"><\/a><\/p>\n<p>And here&#8217;s the output with -a option enabled:<\/p>\n<p><a class=\"fancybox\" id=\"img-apropos-a-option-working\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/apropos-a-option-working.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-3.png\" alt=\"apropos -a\" width=\"500\" height=\"79\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-force-apropos-to-not-trim-output\">Q4. How to force apropos to not trim output?<\/h2>\n<p>As you&#8217;d have seen in output in previous Q&amp;As, the tool trims entries if they are too long. For example, see the highlighted line in the following output:<\/p>\n<p><a class=\"fancybox\" id=\"img-apropos-trim\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/apropos-trim.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-4.png\" alt=\"How to force apropos to not trim output\" width=\"500\" height=\"152\" title=\"\"><\/a><\/p>\n<p>However, if you want, you can force apropos to produce complete lines in output, something which you can do using the -l command line option.<\/p>\n<p><a class=\"fancybox\" id=\"img-apropos-l\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/apropos-l.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-5.png\" alt=\"force apropos to produce complete lines in output\" width=\"500\" height=\"275\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-interpret-apropos-exit-status\">Q5. How to interpret apropos exit status?<\/h2>\n<p>The apropos command produces four different exit status: 0, 1, 2, and 16. Here&#8217;s what each of these represents:<\/p>\n<pre readability=\"10\"> 0\u00a0\u00a0\u00a0\u00a0\u00a0 Successful program execution.<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1\u00a0\u00a0\u00a0\u00a0\u00a0 Usage, syntax or configuration file error.<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0\u00a0 Operational error.<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 16\u00a0\u00a0\u00a0\u00a0 Nothing was found that matched the criteria specified<\/p><\/pre>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>Depending on your work profile, you might not require the apropos command on daily basis, but as you&#8217;d have understood by now, it could be a lifesaver in certain situations. We&#8217;ve discussed some use command line options here. To know more about the tool, head to its <a href=\"https:\/\/linux.die.net\/man\/1\/apropos\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a>.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Flinux-apropos-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-6.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-apropos-command%2F&amp;text=Linux+apropos+Command+Tutorial+for+Beginners+%285+Examples%29&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-7.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-8.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-apropos-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/linux-apropos-command-tutorial-for-beginners-5-examples-9.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, if you ever need help regarding a command, all you need to do is to open its man page. But what if a situation arises wherein the requirement is\u00a0to quickly search the names and descriptions of all available man pages? Well, Linux has got your covered, as there exists a command dubbed apropos &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-5371","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=5371"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5371\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=5371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=5371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=5371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}