Unable to execute bash scripts even as root?
Although not directly pertinent to this particular thread; if a file has come form a Windows system there may be a CR/LF at the end of the line. This would affect all lines in the file, including the initial execution line, and would not be visible if you are viewing the file.
$ ./test.sh
-bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory
To see this, you could cat -A the file: $ cat -A ./test.sh #!/bin/bash^M$ echo "me"^M$
To remove, use dos2unix.
That can happen if you have mounted the file system with the "noexec" option. You should remove it.
Script needs be executable. Use this:
chmod +x <script-name>
Try
ls -la
to see the actual rights and ownership of the file. To see if the chmod command actually worked. You might want to change the ownership along with the mod of the file check : http://www.tuxfiles.org/linuxhelp/fileowner.html