在系统里执行命令:man which

CentOS7.3学习笔记总结(四十七)_第1张图片

which命令用于查找并显示给定命令的绝对路径,环境变量PATH中保存了查找命令时需要遍历的目录。在环境变量PATH设置的目录里查找符合条件的文件。

语法:

which [选项][参数]

选项(常用):

-a,显示所有匹配的可执行的路径

--skip-alias,忽略别名

-V:显示版本信息

参数:

指令名

实例:

[root@localhost ~]# which cp

alias cp='cp -i'

        /bin/cp

[root@localhost ~]# which --skip-alias cp

/bin/cp

[root@localhost ~]# which ls  

alias ls='ls --color=auto'

        /bin/ls

[root@localhost ~]# which -a ls

alias ls='ls --color=auto'

        /bin/ls

        /usr/bin/ls

 

[root@localhost ~]# which -V

GNU which v2.20, Copyright (C) 1999 - 2008 Carlo Wood.

GNU which comes with ABSOLUTELY NO WARRANTY;

This program is free software; your freedom to use, change

and distribute this program is protected by the GPL.