3.3.3 查找执行文件:which/whereis

which用于从系统的PATH变量所定义的目录中查找可执行文件的绝对路径。比如说想查找passwd这个命令在系统中的绝对路径,使用方法如下:


  1. [root@localhost ~]# which passwd
  2. usrbin/passwd

使用whereis也能查到其路径,但是和which不同的是,它不但能找出其二进制文件,还能找出相关的man文件:


  1. [root@localhost ~]# whereis passwd
  2. passwd: usrbin/passwd etcpasswd usrshare/man/man5/passwd.5.gz
  3. usrshare/man/man1/passwd.1.gz