2

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?

Kai - Kazuya Ito
  • 6,454
  • 5
  • 44
  • 50
Spark
  • 188
  • 2
  • 13

1 Answers1

0

Try this one:

sudo bash test.sh

wimdetr
  • 131
  • 2
  • 11