<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Whereis on Cheat Sheet</title><link>/tags/whereis/</link><description>Recent content in Whereis on Cheat Sheet</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 15 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="/tags/whereis/index.xml" rel="self" type="application/rss+xml"/><item><title>locate vs type vs which vs whereis</title><link>/linux/cli/locate-vs-type-vs-which-vs-whereis/</link><pubDate>Mon, 15 Jun 2026 00:00:00 +0000</pubDate><guid>/linux/cli/locate-vs-type-vs-which-vs-whereis/</guid><description>&lt;h1 id="locate-vs-type-vs-which-vs-whereis"&gt;&lt;code&gt;locate&lt;/code&gt; vs &lt;code&gt;type&lt;/code&gt; vs &lt;code&gt;which&lt;/code&gt; vs &lt;code&gt;whereis&lt;/code&gt;&lt;a class="anchor" href="#locate-vs-type-vs-which-vs-whereis"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Comparison of different methods to locate commands and files in Linux.&lt;/p&gt;
&lt;h2 id="comparison"&gt;Comparison&lt;a class="anchor" href="#comparison"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;type&lt;/code&gt;&lt;/strong&gt;: The most reliable way to determine what the shell will execute. Since it is a shell built-in, it identifies shell built-ins, aliases, and functions that external tools miss.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;which&lt;/code&gt;&lt;/strong&gt;: Locates an executable in the user&amp;rsquo;s &lt;code&gt;PATH&lt;/code&gt;. It does not show shell built-ins or aliases by default.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;whereis&lt;/code&gt;&lt;/strong&gt;: Locates the binary, source, and manual page files for a command. It searches a predefined list of standard directories.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;locate&lt;/code&gt;&lt;/strong&gt;: Searches a pre-built database (&lt;code&gt;mlocate.db&lt;/code&gt;) of the entire filesystem. It is extremely fast but may not find recently created files until the database is updated (typically via &lt;code&gt;updatedb&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="usage"&gt;Usage&lt;a class="anchor" href="#usage"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id="type"&gt;&lt;code&gt;type&lt;/code&gt;&lt;a class="anchor" href="#type"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-a&lt;/code&gt;&lt;/strong&gt;: Display all locations containing an executable named &lt;code&gt;&amp;lt;name&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-t&lt;/code&gt;&lt;/strong&gt;: Print a single word describing the type of the command (eg. &lt;code&gt;alias&lt;/code&gt;, &lt;code&gt;keyword&lt;/code&gt;, &lt;code&gt;function&lt;/code&gt;, &lt;code&gt;builtin&lt;/code&gt;, &lt;code&gt;file&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="locate"&gt;&lt;code&gt;locate&lt;/code&gt;&lt;a class="anchor" href="#locate"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-i&lt;/code&gt;&lt;/strong&gt;: Ignore case distinctions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-r&lt;/code&gt;&lt;/strong&gt;: Search using a basic regular expression.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="examples"&gt;Examples&lt;a class="anchor" href="#examples"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Identify command type&lt;/strong&gt;:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ &lt;span style="color:#6639ba"&gt;type&lt;/span&gt; &lt;span style="color:#6639ba"&gt;cd&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6639ba"&gt;cd&lt;/span&gt; is a shell builtin&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Show all locations&lt;/strong&gt;:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ &lt;span style="color:#6639ba"&gt;type&lt;/span&gt; -a ls
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ls is aliased to &lt;span style="color:#0a3069"&gt;`&lt;/span&gt;ls --color&lt;span style="color:#0550ae"&gt;=&lt;/span&gt;auto&lt;span style="color:#f6f8fa;background-color:#82071e"&gt;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ls is /usr/bin/ls&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Find binary and man page&lt;/strong&gt;:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ whereis grep
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;grep: /usr/bin/grep /usr/share/man/man1/grep.1.gz&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Locate all files with a specific name&lt;/strong&gt;:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ locate -i &amp;lt;filename&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>