Linux命令搜索命令whereis与which

一 whereis

1、语法
whereis 命令名
搜索命令所在的路径以及帮助文档所在的位置
选项:
-b:只查找可执行文件
-m:只查找帮助文件
2、实战
  1. [root@localhost ~]# whereis ls
  2. ls:/usr/bin/ls /usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz
  3. [root@localhost ~]# whoami
  4. root
  5. [root@localhost ~]# whatis
  6. whatis what?
  7. [root@localhost ~]# whatis ls
  8. ls (1)- list directory contents
  9. ls (1p)- list directory contents
  10. [root@localhost ~]# whereis -b ls
  11. ls:/usr/bin/ls
  12. [root@localhost ~]# whereis -m ls
  13. ls:/usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz
二 which
1、语法
which 命令名
搜索命令所在路径及别名
2、实战
  1. [root@localhost ~]# which ls
  2. alias ls='ls --color=auto'
  3. /usr/bin/ls
  4. [root@localhost ~]# which pwd
  5. /usr/bin/pwd
  6. [root@localhost ~]# whereis cd
  7. cd:/usr/bin/cd /usr/share/man/man1/cd.1.gz/usr/share/man/man1p/cd.1p.gz
  8. [root@localhost ~]# which cd
  9. /usr/bin/cd
三 PATH环境变量
定义的是系统搜索命令的路径
  1. [root@localhost ~]# echo $PATH
  2. /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

猜你喜欢

转载自cakin24.iteye.com/blog/2391228