I created a simple test script test.sh. I can run it using ./test.sh, but when I try sudo ./test.sh I get an error.
Contents of test.sh:
$ cat test.sh
#!/bin/bash
echo Test worked
echo end
File permissions:
$ ls -l
-rwxrwxrwx 1 spark spark 40 Jan 25 12:20 test.sh
Run script:
$ ./test.sh
Test worked
end
Run script with sudo:
$ sudo ./test.sh
sudo: ./test.sh: command not found
Why could this be happening?