Executing script: "permission denied" - even with 777
Posted: Fri Dec 16, 2011 2:40 pm
[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:
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:
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.
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:
Regardless of the access rights, I've set. I've even tried:./script.sh: Permission denied
No effect.chmod 777 script.sh
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:
Additional information:/dev/sdb1 on /media/storage type ext3 (rw,noexec,nosuid,nodev,noatime,errors=remount-ro,user=pb)
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.