Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 常用搜尋指令大全:find、locate、whereis、which、type

編輯:Linux 教學

1. find:最強大、即時搜尋

find <目錄> <條件> <動作>

  • -name '模式':檔名比對(支援萬用字元)。
  • -type f/d/l...:檔案類型(一般檔/目錄/符號連結)。
  • -size n[c/k]:大小比對。
  • -mtime/-atime/-ctime n:修改/存取/狀態變更時間(天)。
  • -mmin/-amin/-cmin n:分鐘精度。
  • -exec 指令 {} \;:對結果執行指令。

範例:find . -name 'my*' -ls、find / -name httpd.conf -print、find /etc -size -2500c -print。

2. locate:極速資料庫搜尋

搜尋 /var/lib/locatedb 資料庫,非即時。用前先 updatedb 更新。
範例:locate /etc/sh、locate -i ~/m(忽略大小寫)。

3. whereis:專找程式二進制/說明/原始碼

whereis [-b|-m|-s] 指令。whereis grep 同時顯示三者路徑。

4. which:在 PATH 中尋找指令執行檔

回傳第一個找到的路徑。which grep 確認實際執行哪個版本。

5. type:辨識指令來源

type cd → shell 內建。type grep → 外部指令並顯示路徑。type -p grep 等同 which。

Copyright © Windows教程網 All Rights Reserved