在Linux系統中有這幾個搜索命令,find which locate whereisnode
which命令比較經常使用,格式爲which filename, which命令只能查找PATH環境變量中出現的路徑下的可執行文件,用它能夠查看一個可執行文件的絕對路徑以及有沒有別名服務器
[root@test-01 ~]# which ls alias ls='ls --color=auto' /usr/bin/ls
whereis命令不經常使用,格式爲whereis_ -參數 filename_ 參數及含義以下:code
[root@test-01 ~]# whereis ls ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
whereis命令相似於模糊查找,如上所示,運行whereis ls 只要帶有ls字符,就會被列出來字符串
首先安裝mlocate包才能運行locate命令,it
[root@test-01 ~]# yum install -y mlocate
而且首次使用會報錯,由於系統沒有生成mlocate.db這個庫,可使用updatedb命令test
當即生成,若是服務器在跑業務,最好不要執行這條命令, locate命令也是模糊查找,在搜索到的列表中,無論是目錄仍是文件,只要包含咱們所查找的字符,就會被列出來,因此locate不適合精確查找。變量
find命令是最經常使用的搜索命令,格式爲find [路徑] [參數]date
還有一種寫法是-mmin -10 ,這就表示10分鐘之內的文件file
find命令還有一種經常使用的方式:搜索
[root@test-01 ~]# find /usr/bin/ls* /usr/bin/ls /usr/bin/lsattr /usr/bin/lsblk /usr/bin/lscpu /usr/bin/lsinitrd /usr/bin/lslocks
filetype 包括 f =文件 ,b=塊設備,好比磁盤分區。l=軟連接,c=串行端口(字符串設備),d=目錄,s=套接字文件。