Page 1 of 1

Executing script: "permission denied" - even with 777

Posted: Fri Dec 16, 2011 2:40 pm
by ^rooker
[PROBLEM]
I've mounted an external USB drive on a Debian Squeeze installation.
All the folders have proper access rights, and I can read/write all files there. So far so good.

The confusing thing was, that when I tried to execute a bash script (or any other executable) that was stored on that volume, I got a:-bash:
./script.sh: Permission denied
Regardless of the access rights, I've set. I've even tried:
chmod 777 script.sh
No effect.

Copying the file to my home folder, and starting it from there worked.
Puzzling...

[SOLUTION]
For some reason, the drive was mounted with the "noexec" option.
Call mount to see the actual options a drive is mounted with. In my case it looked like this:
/dev/sdb1 on /media/storage type ext3 (rw,noexec,nosuid,nodev,noatime,errors=remount-ro,user=pb)
Additional information:
I think I've figured out, why the "noexec" option was automatically added:
In /etc/fstab, I've had the option "user" enabled, so I didn't have to be root to mount it. After removing the "user" option, and mounting it as root, the "noexec" was gone. Very very strange...

However, if you want to mount a share as non-root, but execute files there, just add the "exec" option in /etc/fstab.