你如何找到命令的目录?

use*_*637 45 command-line

可能重复:
已安装程序的文件夹位置

例如以下是相同的

# /usr/bin/php updateDatabase.php

# php updateDatabase.php
Run Code Online (Sandbox Code Playgroud)

但是我如何推断 php 命令的位置在 /usr/bin 中?

Kno*_*ube 88

您可以使用该whereis命令来查找系统上可执行二进制文件的位置。

例子:

$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
Run Code Online (Sandbox Code Playgroud)

编辑:this answer to a similar question,您也可以使用该which命令。

例子:

$ which ls
/bin/ls
Run Code Online (Sandbox Code Playgroud)


cwe*_*ske 8

当程序可以在不指定完整路径的情况下运行时,它的目录就在您的$PATH变量中。

$ echo $PATH
/home/cweiske/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Run Code Online (Sandbox Code Playgroud)