关于linux:每天学一个-Linux-命令52whereis

0次阅读

共计 765 个字符,预计需要花费 2 分钟才能阅读完成。

昨日举荐:每天学一个 Linux 命令(51):which

命令简介

whereis 命令查找二进制程序、代码等相干文件门路。

然而,和 find 相比,whereis 查找的速度十分快,因为,Linux 会将零碎里的所有文件对立记录在一个数据库文件中,当用户应用 whereis 命令时,它就会间接从这个数据库文件中去查找。而 find 命令则是遍历硬盘来进行查找,故而效率比不上 whereis 命令。

语法格局

whereis [OPTIONS] file name...

选项阐明

-b  #只查找二进制文件
-B< 目录 >  #只在指定的目录下查找二进制文件
-f  #不显示文件名前的门路名称
-m  #只查找阐明文件
-M< 目录 >  #只在指定的目录下查找阐明文件
-s  #只查找原始代码文件
-S< 目录 >  #只在指定的目录下查找原始代码文件
-u  #查找不蕴含指定类型的文件

利用举例

# 将相干的所有文件都查找进去
[root@centos7 ~]# whereis ifconfig
ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
[root@centos7 ~]# whereis top
top: /usr/bin/top /usr/share/man/man1/top.1.gz
#只将二进制文件查找进去
[root@centos7 ~]# whereis -b ifconfig
ifconfig: /usr/sbin/ifconfig
[root@centos7 ~]# whereis -b top
top: /usr/bin/top

相干的查找命令 find 请参考:每天学一个 Linux 命令(20):find

每天学一个 Linux 命令(49):free

每天学一个 Linux 命令(50):date

正文完
 0