• Uncategorized

About linux : Why-command-not-found-in-a-specific-folder-duplicate

Question Detail

I have a .sh file in bin folder, but when I try to use it, the server cannot find it in the folder.

/home/monju/full/app/bin $ls
checkServer.sh  etf_disagg_config_loader.sh  getLogName.sh  mapr
common.sh       findLog.sh                   jgrouplog.sh   phase2b
commonStart.sh  findServer.sh                jmx            postInstallSetup.sh
errorLog.ksh    followLog.sh                 jrebel.sh      probe.sh
etf             genTestFile.ksh              killServer.sh  RMSDisable.sh
/home/monju/full/app/bin $stopServer.sh
bash: stopServer.sh: command not found

while when I use /home/monju/full/app/bin/stopServer.sh, it can be used.

Question Answer

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

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.

Putting . itself in $PATH is considered bad practice.

Use

./stopServer.sh

and make sure you have execution rights.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.