萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 電腦基礎知識 >  >> 電腦基本常識

Linux whereis 指令詳解:快速定位二進制、手冊頁、原始碼檔案

whereis 專門搜尋程式相關檔案(二進制、man page、原始碼),速度極快,因查詢預建資料庫(/var/lib/mlocate/mlocate.db),非即時掃描硬碟。

語法與參數

whereis [-bmsu] [-B 路徑] [-M 路徑] [-S 路徑] 檔名
參數功能
-b僅搜尋二進制執行檔
-m僅搜尋手冊頁
-s僅搜尋原始碼
-u搜尋非上述三類檔案
-B/-M/-S指定對應類型搜尋路徑

實戰範例

whereis svn
# svn: /usr/bin/svn /usr/local/svn /usr/share/man/man1/svn.1.gz

whereis -b svn   # 僅顯示 /usr/bin/svn /usr/local/svn
whereis -m svn   # 僅顯示 /usr/share/man/man1/svn.1.gz
whereis -s svn   # 無輸出 (無原始碼)

注意事項

  • 資料庫預設每週更新一次 (updatedb),新安裝套件可能暫時查不到,手動執行 updatedb 即可。
  • 無法搜尋一般資料檔案(如 .txt、.conf),請改用 find 或 locate。
copyright © 萬盛學電腦網 all rights reserved