I have a rooted phone, and I was playing around with Terminal Emulator. I tried writing a simple shell script (test.sh) :
#!/bin/sh
echo "Hello, World!"
Then I opened terminal emulator, cd'd to the directory my script was in, and typed:
./test.sh
and I got a "permission denied" error. So I tried:
su
./test.sh
Somehow, still permission denied. So I tried (still as root) :
chmod 775 test.sh
busybox chmod 775 test.sh
busybox chmod +X test.sh
None of the 3 gave errors, but ./test.sh still gave permission denied! As a last resort I tried
sh test.sh
That ended up working. Finally.
I'm curious why permission was denied for my own shell script chmodded to 775 when run as root. How can permission be denied for anything as root? How can I fix this and make ./test.sh work?
noexec
flag by default.busybox chmod +X test.sh
is wrong, you’d want to be using+x
(lower-case). Anyway,775
ends up being the same, so it’s thenoexec
issue.