linux檔案名稱尋找which,whereis,locate

來源:互聯網
上載者:User

標籤:linux   which   whereis   locate   

1. 檔案名稱尋找
使用find查詢時,由於磁碟查詢,所以速度較慢,所以linux下查詢更常使用which, whereis, locate來查詢,由於是利用資料庫查詢,所以速度很快。
2. which
我們常用的ls命令,如果我們想知道這些常用命令放在哪兒, 就使用which命令來查詢地址。which使用PATH 環境變數去尋找檔案名稱,which -a 返回所有的查到的命令, 預設返回第一條。
$ which grep/bin/grep$ which llalias ll='ls -l --color=tty'        /bin/ls        #使用alias別名

3. whereis
whereis用來查詢程式名
$ whereiswhereis [ -sbmu ] [ -SBM dir ... -f ] name...-b : 尋找二進位格式檔案-s : 尋找source 源檔案-m : 尋找在說明檔案manual路徑下的檔案-u : 尋找不在上述三個選項中的特殊檔案
例如
$ whereis grepgrep: /bin/grep /usr/share/man/man1/grep.1.gz /usr/share/man/man1p/grep.1p.gz#查詢二進位檔案$ whereis -b grep grep: /bin/grep#查詢手冊說明檔案 man grep $ whereis -m grepgrep: /usr/share/man/man1/grep.1.gz /usr/share/man/man1p/grep.1p.gz

3. locate
linux將系統內檔案列在一個資料庫檔案(/var/lib/slocate/slocate.db)。locate通過資料庫檔案查詢。
一般這個檔案每天更新一次, 配置在/etc/updatedb.conf裡面配置是否每天更新,以及更新目錄。可以手動運行
$ updatedb
來更新資料庫。使用locate,後面跟命令即可
$ locate passwd

地址: http://blog.csdn.net/yonggang7/article/details/37960767

linux檔案名稱尋找which,whereis,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.