which命令:

shows the full path of (shell) commands

查看命令的完整路径,根据环境变量的PATH查找

语法:

which [options] [--] programname [...]

实例:

[root@www1 ~]# which passwd
/usr/bin/passwd
[root@www1 ~]#


whereis命令:

locate the binary, source, and manual page files for a command

查找命令的二进制文件、源码等

语法:

whereis [-bmsu] [-BMS directory...  -f] filename...

选项:

-b 只查找二进制文件

-f 只显示文件,不显示目录

-m 只查找文件说明文档

-s 只查找文件源码

实例:

[root@www1 ~]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz
[root@www1 ~]# whereis -m passwd
passwd: /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz
[root@www1 ~]# whereis -s passwd
passwd:
[root@www1 ~]# whereis -b passwd
passwd: /usr/bin/passwd /etc/passwd