在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=套接字文件。