技術(shù)員聯(lián)盟提供win764位系統(tǒng)下載,win10,win7,xp,裝機純凈版,64位旗艦版,綠色軟件,免費軟件下載基地!

當(dāng)前位置:主頁 > 教程 > 服務(wù)器類 >

linux文件名查找which,whereis,locate

來源:技術(shù)員聯(lián)盟┆發(fā)布時間:2018-07-09 12:23┆點擊:

  1. 文件名查找

  使用find查詢時,由于磁盤查詢,所以速度較慢,所以linux下查詢更常使用which, whereis, locate來查詢,由于是利用數(shù)據(jù)庫查詢,所以速度很快。

  2. which

  我們常用的ls命令,如果我們想知道這些常用命令放在哪兒, 就使用which命令來查詢地址。 which使用PATH 環(huán)境變量去查找文件名, which -a 返回所有的查到的命令, 默認(rèn)返回第一條。$ which grep

  /bin/grep

  $ which ll

  alias ll='ls -l --color=tty'

  /bin/ls

  #使用alias別名

  3. whereis

  whereis用來查詢程序名$ whereis

  whereis [ -sbmu ] [ -SBM dir ... -f ] name...

  -b : 查找二進(jìn)制格式文件

  -s : 查找source 源文件

  -m : 查找在說明文件manual路徑下的文件

  -u : 查找不在上述三個選項中的特殊文件

  例如$ whereis grep

  grep: /bin/grep /usr/share/man/man1/grep.1.gz /usr/share/man/man1p/grep.1p.gz

  #查詢二進(jìn)制文件

  $ whereis -b grep

  grep: /bin/grep

  #查詢手冊說明文件 man grep

  $ whereis -m grep

  grep: /usr/share/man/man1/grep.1.gz /usr/share/man/man1p/grep.1p.gz

  4. locate

  linux將系統(tǒng)內(nèi)文件列在一個數(shù)據(jù)庫文件(/var/lib/slocate/slocate.db)。 locate通過數(shù)據(jù)庫文件查詢。

  一般這個文件每天更新一次, 配置在/etc/updatedb.conf 里面配置是否每天更新,以及更新目錄??梢允謩舆\行$ updatedb

  來更新數(shù)據(jù)庫。使用locate,后面跟命令即可$ locate passwd