Shell script with executable permissions returns "command not found"

Roy Hinkley asked:

I have a shell script file with executable permissions:

-rwxr-xr-x   1 root   root       1147 Jan 26  2017 my_script

Even running it as rootfully qualified (path/to/file/my_script) I get the following error:

-bash: my_script: command not found

SELinux is being enforced and the context label is:


But even attempting to execute with SELinux disabled

Current mode:                   permissive

does not remedy the error. This script has executed as expected in the past.

What am I not understanding – why is this exception being encountered?

CentOS release 6.9

My answer:

my_script is not in your PATH. So you have to provide the path to it when calling it directly.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.