歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux whereis命令詳解

Linux whereis命令詳解

日期:2017/2/28 14:37:33   编辑:Linux教程

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替代的。

--------------------------------------------------

Linux下的文件查找——type whereis which find locate http://www.linuxidc.com/Linux/2013-06/86038.htm

Copyright © Linux教程網 All Rights Reserved