which 命令的功能是用于查找命令文件,能够快速搜索二进制程序所对应的位置。如果我们既不关心同名文件(find与locate),也不关心命令所对应的源代码和帮助文件(whereis),仅仅是想找到命令本身所在的路径,那么这个 which 命令就太合适了。
目录
一、语法格式
which [参数] 文件
二、常用参数
-V | 显示版本信息 |
三、命令实战
3.1 查找某个指定命令文件所在位置
[root@linux ~]# which cd
/usr/bin/cd
3.2 如果命令有别名,会显示别名
[root@linux ~]# which rm
alias rm='rm -i'
/usr/bin/rm
3.3 查找多个命令文件所在位置
[root@linux ~]# which find grep whereis less touch
alias grep='grep --color=auto'
/usr/bin/grep
/usr/bin/find
/usr/bin/whereis
/usr/bin/less
/usr/bin/touch