locate -- 查找文件或者目录
[root@localhost ssx-test]# locate /etc/passwd
/etc/passwd
/etc/passwd-
搜索/etc目录下所有以pass开头的文件
[root@localhost ssx-test]# locate /etc/pass
/etc/passwd
/etc/passwd-
搜索/etc目录下所有以sh开头的文件
[root@localhost ssx-test]# locate /etc/sh
/etc/shadow
/etc/shadow-
/etc/shells
搜索/etc目录下所有以sh开头的文件,忽略大小写
[root@localhost ssx-test]# locate -i /etc/sh
/etc/shadow
/etc/shadow-
/etc/shells
[root@localhost ssx-test]# cd
[root@localhost ~]# pwd
/root
[root@localhost ~]# ls
anaconda-ks.cfg index.html ssx-test
[root@localhost ~]# locate -i ~/ss
/root/ssx-test
/root/ssx-test/index-test.html
[root@localhost ~]# locate index-test.html
/root/ssx-test/index-test.html
[root@localhost ~]#
which -- 查找系统PATH环境变量目录下的命令(绝对路径)
示例:which ls
[root@localhost ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
[root@localhost ~]# rpm -qf /usr/bin/ls
coreutils-8.22-21.el7.x86_64
[root@localhost ~]#
whereis
-- 查找文件索引数据库下的命令/源文件/man文件.非PATH变量查找,所有查找的面比which要广.
-- 只搜索二进制文件(参数-b)、man说明文件(参数-m)和源代码文件(参数-s)。如果省略参数,则返回所有信息。
[root@localhost ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz