{"id":7176,"date":"2021-06-12T13:14:38","date_gmt":"2021-06-12T13:14:38","guid":{"rendered":"https:\/\/linuxways.net\/?p=7176"},"modified":"2021-06-12T13:14:38","modified_gmt":"2021-06-12T13:14:38","slug":"linux-whereis-command","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/linux-whereis-command\/","title":{"rendered":"Linux Whereis Command"},"content":{"rendered":"<p>The <strong>whereis<\/strong> command is a command-line tool that helps you locate the source or binary and manual pages of a Linux command. In this brief guide, we will try and provide insights into how you can use the whereis command.<\/p>\n<h2><strong>Whereis command basic syntax<\/strong><\/h2>\n<p>The whereis utility takes the syntax shown.<\/p>\n<pre><strong>$ whereis [OPTIONS] filename<\/strong><\/pre>\n<p>Let\u2019s now take a few examples.<\/p>\n<h2><strong>Search for binary and man pages of a command<\/strong><\/h2>\n<p>Without any options, the whereis utility provides both the path to the binary and the man pages of a Linux command.<\/p>\n<p>Suppose you want to find the binary location of the <strong>ls <\/strong>command including the man pages. To achieve his, run the command:<\/p>\n<pre><strong>$ whereis ls<\/strong><\/pre>\n<p>From the output, the binary is found in <strong>\/usr\/bin\/<\/strong> path and manual pages in the <strong>\/usr\/share\/man\/man1\/ls.1.gz <\/strong>path.<\/p>\n<p>Let\u2019s take yet another example. To locate the binary path &amp; man pages of <strong>cat <\/strong>command, execute:<\/p>\n<pre><strong>$ whereis cat<\/strong><\/pre>\n<p>Likewise, the binary is found in <strong>\/usr\/bin\/cat<\/strong> path and manual pages in <strong>\/usr\/share\/man\/man1\/cat.1.gz <\/strong>path.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"752\" height=\"308\" class=\"wp-image-7177\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-394.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-394.png 752w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-394-300x123.png 300w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/p>\n<h2><strong>Provide more than one command as an argument<\/strong><\/h2>\n<p>Additionally, you can provide multiple commands as arguments as follows:<\/p>\n<pre><strong>$ whereis command1 command2 \u2026<\/strong><\/pre>\n<p>For example, to simultaneously find the binary location and man pages of two commands: <strong>pwd <\/strong>and <strong>uptime <\/strong>run the command:<\/p>\n<pre><strong>$ whereis pwd uptime<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"230\" class=\"wp-image-7178\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-395.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-395.png 750w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-395-300x92.png 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<h2><strong>Locate the man pages only<\/strong><\/h2>\n<p>Use the <strong>-m<\/strong> option o only view the path to the man pages of the command. The example below provides the path to the man pages of the <strong>ls<\/strong> command.<\/p>\n<pre><strong>$ whereis -m ls<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"722\" height=\"282\" class=\"wp-image-7179\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-396.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-396.png 722w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-396-300x117.png 300w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/p>\n<h2><strong>Search for the binary paths only <\/strong><\/h2>\n<p>If you only want to search for the binary paths only and leave out the man pages, use the <strong>-b <\/strong>option as shown below.<\/p>\n<pre><strong>$ whereis -b ls<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"269\" class=\"wp-image-7180\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-397.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-397.png 721w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-397-300x112.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/strong><\/p>\n<h2><strong>Search for the source files only <\/strong><\/h2>\n<p>To search for source files only, use the <strong>-s <\/strong>option as shown.<\/p>\n<pre><strong>$ whereis -s cp<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"757\" height=\"304\" class=\"wp-image-7181\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-398.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-398.png 757w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-398-300x120.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/p>\n<h2><strong>Limit places that whereis can search for man pages<\/strong><\/h2>\n<p>By default, the <strong>whereis <\/strong>utility retrieves all the man pages for a command. To restrict the utility to search in specific man pages, use the <strong>-M <\/strong>option followed by the man page and thereafter the <strong>-f <\/strong>option followed by the command.<\/p>\n<p>In the example below, the <strong>whereis <\/strong>utility searches for man pages of the <strong>mkdir <\/strong>command in twp paths: <strong>\/usr\/share\/man\/man2\/mkdir.2.gz <\/strong>and <strong>\/usr\/share\/man\/man1\/mkdir.1.gz.<\/strong><\/p>\n<pre><strong>$ whereis mkdir<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"797\" height=\"232\" class=\"wp-image-7182\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-399.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-399.png 797w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-399-300x87.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-399-768x224.png 768w\" sizes=\"auto, (max-width: 797px) 100vw, 797px\" \/><\/p>\n<p>Here, we have limited the <strong>whereis <\/strong>utility to search for the man pages in the <strong>\/usr\/share\/man\/man2<\/strong> path only and ignore the other location.<\/p>\n<pre><strong>$ whereis -M \/usr\/share\/man\/man2 -f mkdir<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"796\" height=\"232\" class=\"wp-image-7183\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-400.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-400.png 796w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-400-300x87.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-400-768x224.png 768w\" sizes=\"auto, (max-width: 796px) 100vw, 796px\" \/><\/p>\n<h2><strong>Limit places that whereis can search for binaries<\/strong><\/h2>\n<p>Similarly, you can limit the location that <strong>whereis <\/strong>searches for binaries. In the command below, <strong>whereis <\/strong>searches for binaries in two locations: <strong>\/usr\/bin\/pwd<\/strong> and <strong>\/usr\/include\/pwd.h<\/strong>.<\/p>\n<pre><strong>$ whereis pwd<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"799\" height=\"198\" class=\"wp-image-7184\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-401.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-401.png 799w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-401-300x74.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-401-768x190.png 768w\" sizes=\"auto, (max-width: 799px) 100vw, 799px\" \/><\/p>\n<p>Using the <strong>-B <\/strong>option, as shown, we have restricted the utility to search for the binaries in the <strong>\/usr\/bin <\/strong>path only.<\/p>\n<pre><strong>$ whereis -B \/usr\/bin -f pwd<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"201\" class=\"wp-image-7185\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-402.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-402.png 801w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-402-300x75.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-402-768x193.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/p>\n<h2><strong>Check the version <\/strong><\/h2>\n<p>To check the version of the <strong>whereis<\/strong> command, execute:<\/p>\n<pre><strong>$ whereis --version<\/strong><\/pre>\n<p>OR<\/p>\n<pre><strong>$ whereis -V<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"249\" class=\"wp-image-7186\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-403.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-403.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-403-300x103.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<h2><strong>Get help with whereis utility<\/strong><\/h2>\n<p>For additional <strong>whereis <\/strong>command options, run the command.<\/p>\n<pre><strong>$ whereis --help<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"798\" height=\"477\" class=\"wp-image-7187\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-404.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-404.png 798w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-404-300x179.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-404-768x459.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/06\/word-image-404-501x300.png 501w\" sizes=\"auto, (max-width: 798px) 100vw, 798px\" \/><\/p>\n<h2><strong>Wrapping up<\/strong><\/h2>\n<p>That was a quick overview of the <strong>whereis <\/strong>command. Hopefully, you have learned the ropes and can use the utility to locate the binaries and manual pages for various commands.<\/p>","protected":false},"excerpt":{"rendered":"<p>The whereis command is a command-line tool that helps you locate the source or binary and manual pages of a Linux command. In this brief guide, we will&hellip;<\/p>","protected":false},"author":1,"featured_media":7243,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,5,83,165,2],"tags":[368],"class_list":["post-7176","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-whereis-command"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/7176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=7176"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/7176\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/7243"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=7176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=7176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=7176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}