標籤:linux 尋找 檔案
一、which
which命令返回可執行命令的執行檔案路徑.(但是僅僅搜尋PATH下的目錄)
[[email protected]_test1 yum.repos.d]# which vim/usr/bin/vim
二、whereis
whereis命令也返回可執行命令的檔案路徑。比which多的是:會同時返回其man page的路徑。
[[email protected]_test1 yum.repos.d]# whereis vimvim: /usr/bin/vim /usr/share/vim /usr/share/man/man1/vim.1.gz
三、locate
locate命令返回所有檔案的目錄。
該命令訪問Linux內建資料庫,返回包含查詢關鍵字的檔案路徑。
locate sss.rpm#更新目錄資料庫的命令:updatedb
四、find
find會實際掃描檔案系統。(需要指定查詢目錄)(還可以加-ls以高大上 - -)
#普通青年:根據名字尋找[[email protected]_manager_test Desktop]# find /root/ -name temp/root/Desktop/temp#話嘮青年:尋找並列出檔案資訊[[email protected]_manager_test Desktop]# find /root/ -name temp -ls800598 4 -rwxr--r-- 1 root root 528 May 30 10:04 /root/Desktop/temp#人肉少年:根據檔案使用者尋找[[email protected]_manager_test Desktop]# find /root/Desktop/ -user root -ls800606 2033704 -rw-r--r-- 1 root root 2082507589 Aug 28 11:08 /root/Desktop/cdh5.zip800598 4 -rwxr--r-- 1 root root 528 May 30 10:04 /root/Desktop/temp802726 68 -rw-r--r-- 1 root root 63043 Aug 29 14:08 /root/Desktop/log4j.log798924 586196 -rw-r--r-- 1 root root 600259606 Aug 28 11:07 /root/Desktop/cm.zip#組合條件:多種口味,總有一款適合你#【1】 -o “或”[[email protected]_manager_test Desktop]# find /root/Desktop/ -user cdh -o -group root -ls800606 2033704 -rw-r--r-- 1 root root 2082507589 Aug 28 11:08 /root/Desktop/cdh5.zip802726 68 -rw-r--r-- 1 root root 63043 Aug 29 14:08 /root/Desktop/log4j.log798924 586196 -rw-r--r-- 1 root root 600259606 Aug 28 11:07 /root/Desktop/cm.zip#【2】 -a “與”[[email protected]_manager_test Desktop]# find /root/Desktop/ -user cdh -a -group root -ls800598 4 -rwxr--r-- 1 cdh root 528 May 30 10:04 /root/Desktop/temp#【3】 -type 檔案類型[[email protected]_manager_test Desktop]# find /root/Desktop/ -user root -a -type d -ls916267 4 drwxr-xr-x 2 root root 4096 Sep 19 17:26 /root/Desktop/en#【4】 -perm 檔案許可權[[email protected]_manager_test Desktop]# find /root/Desktop/ -perm 644 -ls800606 2033704 -rw-r--r-- 1 root root 2082507589 Aug 28 11:08 /root/Desktop/cdh5.zip802726 68 -rw-r--r-- 1 root root 63043 Aug 29 14:08 /root/Desktop/log4j.log798924 586196 -rw-r--r-- 1 root root 600259606 Aug 28 11:07 /root/Desktop/cm.zip
linux 檔案尋找及定位