uTools-Manuals/docs/linux/whereis.html
2019-04-21 11:50:48 +08:00

40 lines
2.6 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="whereis">whereis</h1>
<p>查找二进制程序、代码等相关文件路径</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>whereis命令</strong> 用来定位指令的二进制程序、源代码文件和man手册页等相关文件的路径。</p>
<p>whereis命令只能用于程序名的搜索而且只搜索二进制文件参数-b、man说明文件参数-m和源代码文件参数-s。如果省略参数则返回所有信息。</p>
<p>和find相比whereis查找的速度非常快这是因为linux系统会将 系统内的所有文件都记录在一个数据库文件中当使用whereis和下面即将介绍的locate时会从数据库中查找数据而不是像find命令那样 过遍历硬盘来查找效率自然会很高。 但是该数据库文件并不是实时更新默认情况下时一星期更新一次因此我们在用whereis和locate 查找文件时有时会找到已经被删除的数据或者刚刚建立文件却无法查找到原因就是因为数据库文件没有被更新。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">whereis(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-b只查找二进制文件
-B&lt;目录&gt;:只在设置的目录下查找二进制文件;
-f不显示文件名前的路径名称
-m只查找说明文件
-M&lt;目录&gt;:只在设置的目录下查找说明文件;
-s只查找原始代码文件
-S&lt;目录&gt;只在设置的目录下查找原始代码文件;
-u查找不包含指定类型的文件。</code></pre>
<h3 id="参数">参数</h3>
<p>指令名要查找的二进制程序、源文件和man手册页的指令名。</p>
<h3 id="实例">实例</h3>
<p>将相关的文件都查找出来</p>
<pre><code class="language-bash">[root@localhost ~]# whereis tomcat
tomcat:
[root@localhost ~]# whereis svn
svn: /usr/bin/svn /usr/local/svn /usr/share/man/man1/svn.1.gz</code></pre>
<p>说明tomcat没安装找不出来svn安装找出了很多相关文件</p>
<p>只将二进制文件查找出来 </p>
<pre><code class="language-bash">[root@localhost ~]# whereis -b svn
svn: /usr/bin/svn /usr/local/svn
[root@localhost ~]# whereis -m svn
svn: /usr/share/man/man1/svn.1.gz
[root@localhost ~]# whereis -s svn
svn:
</code></pre>
<p>说明:<code>whereis -m svn</code>查出说明文档路径,<code>whereis -s svn</code>找source源文件。</p>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->