which命令只能用来查找PATH环境变量中出现的路径下的可执行文件。有时咱们不知道某个命令的绝对路径时可使用which命令来查找node
[root@localhost ~]# which ls alias ls='ls --color=auto' /usr/bin/ls
whereis命令经过预生成的一个文件列表库查找与给出的文件名相关的文件,使用格式为:whereis 参数 文件名 其参数以下bash
[root@localhost ~]# whereis ls ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
locate命令相似于whereis,也是经过查找预生成的文件列表库来告诉用户要查找的文件在哪里,后面直接跟文件名。通常机器上没有安装这个软件包,使用yum install -y mlocate 安装。在安装完毕以后第一次使用会报错,由于系统上没有生成文件列表库,能够经过使用updatedb命令当即生成这个库,可是若是机器上正运行着重要业务最好不要运行这个命令,由于一旦执行,服务器的压力会增长。服务器
[root@localhost ~]# locate more /usr/bin/more /usr/bin/xzmore /usr/bin/zmore /usr/share/bash-completion/completions/more /usr/share/man/man1/more.1.gz /usr/share/man/man1/xzmore.1.gz /usr/share/man/man1/zmore.1.gz [root@localhost ~]#
这个命令精确度不高,每每搜索结果会不少,因此这个命令并不经常使用。code
find命令是最经常使用的搜索命令,格式为find [路径] [参数]字符串
还有一种写法是-mmin -10 ,这就表示10分钟之内的文件it
find命令还有一种经常使用的方式:io
[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 包括test