您的位置:首页 > 其它

[一文一命令]whereis命令详解

2013-12-21 22:27 274 查看

Whereis命令

功能简述:whereis命令是定位可执行文件、源代码文件、帮助文件在文件系统中的位置。这些文件的属性应属于原始代码,二进制文件,或是帮助文件。whereis 程序还具有搜索源代码、指定备用搜索路径和搜索不寻常项的能力。和find相比,whereis查找的速度非常快,这是因为linux系统会将系统内的所有文件都记录在一个数据库文件中,当使用whereis和下面即将介绍的locate时,会从数据库中查找数据,而不是像find命令那样,通过遍历硬盘来查找,效率自然会很高。但此数据库没有实时更新,有时候新建的文件会找不到,需要手动更新此数据库。
语法:whereis [-bmsu] [BMS 目录名-f ] 文件名
命令参数:
-b 定位可执行文件。
-m 定位帮助文件。
-s 定位源代码文件。
-u 搜索默认路径下除可执行文件、源代码文件、帮助文件以外的其它文件。
-B 指定搜索可执行文件的路径。
-M 指定搜索帮助文件的路径。
-S 指定搜索源代码文件的路径。

查找和crontab文件相关的文件
[atong@LiWenTong tmp]$ whereis crontab
crontab: /usr/bin/crontab /etc/crontab/usr/share/man/man1/crontab.1.gz /usr/share/man/man5/crontab.5.gz/usr/share/man/man1p/crontab.1p.gz

指定查找的文件类别
[atong@LiWenTong tmp]$ whereis -b crontab―》指定查找二进制文件,也就是可执行文件
crontab: /usr/bin/crontab /etc/crontab
[atong@LiWenTong tmp]$ whereis -m crontab-->指定查找帮助文件
crontab: /usr/share/man/man1/crontab.1.gz/usr/share/man/man5/crontab.5.gz /usr/share/man/man1p/crontab.1p.gz
[网络上的实例]
mao:~# whereis vi
vi: /usr/bin/vi /usr/share/vi /usr/share/man/man1/vi.1.gz
mao:~# whereis man
man: /usr/bin/man /usr/local/man /usr/share/man /usr/share/man/man1/man.1.gz /usr/share/man/man7/man.7.gz
mao:~# whereis yes
yes: /usr/bin/yes /usr/share/man/man1/yes.1.gz
mao:~# whereis echo
echo: /bin/echo /usr/share/man/man1/echo.1.gz
mao:~# whereis less
less: /usr/bin/less /usr/share/man/man1/less.1.gz
mao:~# whereis fcitx
fcitx: /usr/bin/fcitx /usr/share/fcitx
------------------------后续自我小结---------------
whereis其实跟我们的locate和which的功能很像,也是能够查找执行文件和文件,还能够查找帮助文件。基本这个命令应该可以被which和locate替代的。
--------------------------------------------------

本文出自 “从头开始” 博客,请务必保留此出处http://atong.blog.51cto.com/2393905/1343613
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: