Executing script: "permission denied" - even with 777

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Executing script: "permission denied" - even with 777

Post 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.
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply