Error message: bash: command not found

This is openHABian v1.6.2 related:
After a fresh install I cannot run script files from command line anymore.
executing results in:

-bash: command not found

However, this works: bash
This problem has been verfied with another User.
Could anybody please help?

1 Like

your script is not marked as executable in Linux? ( not an openHAB issue)

show the permissions and the first lines of

1 Like

scripts were running under the “old” OH2 system

Before posting this issue I made sure they are executable und permissions are set with the following commands:

sudo chmod 777 /etc/openhab/scripts/
sudo chmod +x /etc/openhab/scripts/ $1

file rights ls -al:
-rwxrwxrwx 1 os openhab 150 Jan 3 12:59

first line:

You say it works when running from the command line. What is the output of which bash ? Perhaps the first line of the script is incorrect for your OS. Sometimes it is in /usr/bin

what OS do you run ?

“bash” is available in both directories:
I am not a Linux expert. I am just using the regular openhabian 1.6.2 image.

The command I asked would show exactly which one works though.

what do you mean? As said openHABian 1.6.2 Does that not indicate what my OS is?
If not, please tell me what I need to do to answer your question

sorry, now I got you.


but even if I change the first line of my script, it does not solve the problem

openHABian is not an OS but scripts you install on top of one. Which one ?
Or did you use the image?
What’s your HW ?

As said, I installed your openHABian 1.6.2 image.
HW is Raspberry Pi 4 4GB

you didn’t say “image”.

Your problem then is that your script is bad. bash lives in /bin not /usr/bin.

[21:08:12] openhabian@openhab:~$ ls /usr/bin/bash
ls: cannot access '/usr/bin/bash': No such file or directory
[21:08:12] openhabian@openhab:~$ ls /bin/bash

ok, then you have a different image installed.

it makes no difference if I run the script with




is there anything else I can do? 1.6.0 image was working fine - no problems at all

Where is your script located in ?
The error message means that cannot be found by using the content of the PATH variable.
If you do a

echo $PATH

you will see the directories that are being used to search for


I assume that you are executing the script from within the directory where the script is located.
So you either need to move the script to a directory that is listed in the PATH environment variable or you need to add the directory to the PATH environment variable.

what I do not understand is, why there haven’t been any problems with openHABian 1.6.0 image…

Please help me to understand:
If I change the directory to where the .sh script is located, e.g. /etc/openhab/scripts and run it from there, the path to script location does not need to be in PATH-Environent, right? At least this is how it works under DOS or Windows cmd (I know, this does not necessarily mean it is the unser Linux…)

From my little experience: I think under 1.6.0 I was able to execute any .sh script from any location

To be able to run a script from the current directory you are in you need to add the . ( dot ) direcotry to the PATH.

then the . needs to be in the PATH.
You also can run the script by prepending the dot like: ./ ( as long as you are in the directory ) or /etc/openhab/scripts/ to execute the script.
Dot is not included in the search PATH e.g. for root to not get vulnerable scripts being executed by accident. E.g. In case a user that would like root to get executed something puts a replacement for the ls command in his directory then asks root to change into his directory and do a ls command instead of the system ls command the users ls command would be executed in case root would have . as first item in his PATH environment variable.

I do not know all the history of openahbian but in case you mean you could store scripts like /dirA/A, /dirB/B, /dirC/C and then goto e.g. /etc and run A, B, C I definitely can say that this did not work as the system needs to look into the PATH variable to find this scripts, executables.

So just make sure that you always use the absolute path and script name and it will be executed and does not need to be found by the PATH environment variable.

1 Like

Many thanks Wolfgang. I appreciate your answers.
With regards to executing script files from various directories.
I am 100% sure that it did work in

  • any subfolder I created in my home directory and
  • in any subfolder of /etc/openhab.