且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么在特定文件夹中找不到命令?

更新时间:2023-11-06 10:14:04

仅仅因为它位于名为 bin 的目录中并不意味着Shell可以神奇地找到它.

Just because it's in a directory named bin doesn't mean the shell can magically find it.

您需要将完整路径放在您的 $ PATH 环境变量中,或将其符号链接到已经在 $ PATH 中的某个位置.

You need to put the full path in your $PATH environment variable, or symlink it to somewhere that's in the $PATH already.

当然,如果您只想从当前目录运行它,则***使用

Of course, if you only want to run it from the current directory, it's best to use

$ ./stopServer.sh

与您给出的长绝对路径相同,仅使用相对路径语法,其中.表示当前目录.

Which is the same as the long absolute path you gave, only using relative path syntax where . means current directory.

.本身放入 $ PATH 中被认为是不良做法.

Putting . itself in $PATH is considered bad practice.