Linux 之 whereis 命令

Linux whereis 命令用于定位查找一个命令的二进制、源文件或帮助文件。不过这些文件一般是位于特定目录的。

其他的程序定位可以考虑使用locate命令。

官方的定义为:

whereis – locate the binary, source, and manual page files for a command

使用语法

使用语法如下:

1$ whereis [options] [-BMS directory… -f] name…

其他的选项可以为:

  • -b : 查找二进制文件
  • -m:查找手册
  • -s:查找源文件
  • -B <directory>  在设置的目录下查找二进制文件。
  • -M <directory>  在设置的目录下查找说明文件。
  • -S <directory>  在设置的目录下查找原始代码文件。 

实例

比如查找bash的位置,输入如下命令:

1$ whereis bash

2bash: /usr/bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz

可以看到,以上的输出信息从左至右分别为程序名、bash路径、bash的man帮助手册路径。

单独查找文件

可以通过不同的参数来查找不同的文件,如下:

1# 查找二进制文件

2$ whereis -b bash

3bash: /usr/bin/bash /etc/bash.bashrc

4

5# 查找帮助文件

6$ whereis -m bash

7bash: /usr/share/man/man1/bash.1.gz

8

9# 查找源文件

10$ whereis -s bash

11bash:

声明:文中观点不代表本站立场。本文传送门:https://eyangzhen.com/92725.html

(0)
联系我们
联系我们
分享本页
返回顶部