寻找可执行文件,这个指令是根据"PATH"这个环境变量所规范的路径,去搜寻"可执行文件"的文件名~所以,重点是找出"可执行文件"而已!而且which后面接的是"完整文件名"##语法[root@sutd
寻找可执行文件,这个指令是根据"PATH"这个环境变量所规范的路径,去搜寻"可执行文件"的文件名~所以,重点是找出"可执行文件"而已!而且which后面接的是"完整文件名"
##语法
[root@sutdy ~]# which [-a] command
##参数
-a : 将所有由PATH目录中可以找到的指令均列出,而不止第一个被找到的指令名称
##范例
范例一:搜寻ifconfig这个指令的完整文件名
[root@study ~]# which ifconfig/usr/bin/ifconfig
范例二:用which去找出which的文件名
[root@study ~]# which whichalias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' /usr/bin/alias /usr/bin/which# 会有两个which,其中一个是alias。# 这就是所谓的"命令别名",意思是输入which会等于后面接的那串指令!
范例三:请找出history这个指令的完整文件名
[root@study ~]# which history/usr/bin/which: no history in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)[root@study ~]# history --help-bas: history: --:invalid optionhistory: usage history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]# 怎么可能没有history,我明明能够用root执行history。# 这是因为history是"bash内置的指令"