I am trying to run a shell script with elevated privileges on photon os by using su.
When doing this though I get an error Unknown command: `./install-salt.sh'
The command I am running with su is: su -c './install-salt.sh'
Any help appreciated
When you write ./install-salt.sh that is a relative path, since . means current directory. You should use an absolute path like /home/you/install-salt.sh instead since the shell you're spawning to run that command has another idea of what the "current directory" is.
Using absolute paths is good practice in other situations too, like cronjobs for example, or systemd configurations, where they are often required.
Also, in your case, ensure the file is executable (permission +x).
/usr/local/bin/ and run chmod +x install-salt.sh, then verify it by running ls -l install-salt.sh
#!/bin/bash which tells it how to run it. If you miss that, add it or tell the command explicitly to have bash run it, like su -c '/bin/bash [filename]'
/bin/bash I get the same error again, Unknown command.
#! /bin/sh I made a quick shellscript (that only exits itself) as a testbed and it seems to work. Make sure it has execute permissions as well, of course.