whereis
命令只能用於程式名的搜索,而且只搜索二進位檔(參數-b)、man說明文件(參數-m)和源代碼檔(參數-s)。如果省略參數,則返回所有資訊。
和find
相比,whereis
查找的速度非常快,這是因為linux系統會將 系統內的所有檔都記錄在一個資料庫檔中,當使用whereis
和下麵即將介紹的locate
時,會從資料庫中查找數據,而不是像find
命令那樣,通 過遍曆硬碟來查找,效率自然會很高。
但是該資料庫檔並不是即時更新,默認情況下時一星期更新一次,因此,在用whereis
和locate
查找檔時,有時會找到已經被刪除的數據,或者剛剛建立檔,卻無法查找到,原因就是因為資料庫檔沒有被更新。
1.命令格式
whereis [-bmsu] [BMS 目錄名 -f ] 檔案名
2.命令功能
whereis
命令是定位可執行檔、源代碼檔、幫助檔在檔系統中的位置。這些檔的屬性應屬於原始代碼,二進位檔,或是幫助檔。whereis
程式還具有搜索源代碼、指定備用搜索路徑和搜索不尋常項的能力。
3.命令參數
-b
- 定位可執行檔。-m
- 定位幫助檔。-s
- 定位源代碼檔。-u
- 搜索默認路徑下除可執行檔、源代碼檔、幫助檔以外的其他檔。-B
- 指定搜索可執行檔的路徑。-M
- 指定搜索幫助檔的路徑。-S
- 指定搜索源代碼檔的路徑。
4.使用實例
實例1:將和xx檔相關的檔都查找出來
命令:
whereis python
執行演示及輸出:
[zaixian@localhost ~]$ whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz
[zaixian@localhost ~]$ whereis git
git:[zaixian@localhost ~]$
說明:
git
沒安裝,找不出來,python安裝了,所以找出了很多相關檔
實例2:只將二進位檔查找出來
命令:
whereis -b python
執行演示及輸出:
[zaixian@localhost ~]$ whereis -b python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7