linux 檔案尋找及定位

來源:互聯網
上載者:User

標籤: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 檔案尋找及定位

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.