CentOS裡whereis命令詳解整理

來源:互聯網
上載者:User

Whereis命令

功能簡述:whereis命令是定位可執行檔、原始碼檔案、協助檔案在檔案系統中的位置。這些檔案的屬性應屬於原始代碼,二進位檔案,或是協助檔案。whereis 程式還具有搜尋原始碼、指定備用搜尋路徑和搜尋不尋常項的能力。和find相比,whereis尋找的速度非常快,這是因為linux系統會將系統內的所有檔案都記錄在一個資料庫檔案中,當使用whereis和下面即將介紹的locate時,會從資料庫中尋找資料,而不是像find命令那樣,通過遍曆硬碟來尋找,效率自然會很高。但此資料庫沒有即時更新,有時候建立的檔案會找不到,需要手動更新此資料庫。

文法:whereis [-bmsu] [BMS 目錄名-f ] 檔案名稱

命令參數:

-b 定位可執行檔。

-m 定位協助檔案。

-s 定位原始碼檔案。

-u 搜尋預設路徑下除可執行檔、原始碼檔案、協助檔案以外的其它檔案。

-B 指定搜尋可執行檔的路徑。

-M 指定搜尋協助檔案的路徑。

-S 指定搜尋原始碼檔案的路徑。


尋找和crontab檔案相關的檔案

[atong@LiWenTong tmp]$ whereis crontab

crontab: /usr/bin/crontab /etc/crontab/usr/share/man/man1/crontab.1.gz /usr/share/man/man5/crontab.5.gz/usr/share/man/man1p/crontab.1p.gz


指定尋找的檔案類別

[atong@LiWenTong tmp]$ whereis -b crontab—》指定尋找二進位檔案,也就是可執行檔

crontab: /usr/bin/crontab /etc/crontab

[atong@LiWenTong tmp]$ whereis -m crontab-->指定尋找協助檔案

crontab: /usr/share/man/man1/crontab.1.gz/usr/share/man/man5/crontab.5.gz /usr/share/man/man1p/crontab.1p.gz

[網路上的執行個體]

mao:~# whereis vi

vi: /usr/bin/vi /usr/share/vi /usr/share/man/man1/vi.1.gz

mao:~# whereis man

man: /usr/bin/man /usr/local/man /usr/share/man /usr/share/man/man1/man.1.gz /usr/share/man/man7/man.7.gz

mao:~# whereis yes

yes: /usr/bin/yes /usr/share/man/man1/yes.1.gz

mao:~# whereis echo

echo: /bin/echo /usr/share/man/man1/echo.1.gz

mao:~# whereis less

less: /usr/bin/less /usr/share/man/man1/less.1.gz

mao:~# whereis fcitx

fcitx: /usr/bin/fcitx /usr/share/fcitx

------------------------後續自我小結---------------

whereis其實跟我們的locate和which的功能很像,也是能夠尋找執行檔案和檔案,還能夠尋找協助檔案。基本這個命令應該可以被which和locate替代的。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.