简介

whereis命令查找速度非常快,因为它不是在磁盘中乱找,而是在一个数据库中查询; 是系统自动创建的,包含有本地所有文件的信息,并且每天通过自动执行 updatedb命令 更新一次。正因为这样,whereis命令的搜索结果有时候会不准确,比如刚添加的文件可能搜不到, 原因就是该数据库文件没有被更新。

格式

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

常用参数

-b 查找二进制程序或命令
-B 从指定目录下 查找二进制程序或命令
-m 查找man手册文件
-M 从指定目录下 查找man手册文件
-s 只查找源代码文件
-S 从指定目录下 查找源代码文件
-l 查看 whereis 的搜索路径

示例

  1. ## 不加参数 默认都显示
  2. [root@localhost ~]# whereis ls
  3. ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
  4. [root@localhost ~]# whereis -b ls
  5. ls: /usr/bin/ls
  6. [root@localhost ~]# whereis -m ls
  7. ls: /usr/share/man/man1/ls.1.gz
  8. [root@localhost ~]# whereis -l
  9. bin: /usr/bin
  10. bin: /usr/sbin
  11. bin: /usr/lib
  12. bin: /usr/lib64
  13. bin: /etc
  14. bin: /usr/etc
  15. bin: /usr/games
  16. bin: /usr/local/bin
  17. bin: /usr/local/sbin
  18. bin: /usr/local/etc
  19. bin: /usr/local/lib
  20. bin: /usr/local/games
  21. bin: /usr/include
  22. 。。。。。