I'm trying to execute some scripts, which are located on my data partition, from the shell, but I have a problem with permissions.
bash: /media/storage/ss/script.py: Permission denied
Before running I provided the script execute permission with:
chmod +x script.py
Likely the problem is related to settings in my fstab-file. I have tried to edit my /etc/fstab settings. Currently they are:
UUID=F6C09DB5C09D7C95 /media/storage/ ntfs-3g uid=1000,gid=1000,umask=0022,auto,rw 0 0
However I cannot see these updated uid and gid when I run:
Edit:
~$ stat /media/storage
Output:
File: /media/storage/
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 804h/2052d Inode: 5 Links: 1
Access: (0777/drwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
So how do I change my /etc/fstab file to have execute permission on my scripts on my ntfs data partition?
— Edit —
~$ stat /media/storage/ss/script.py
Output:
File: /media/storage/ss/script.py
Size: 525 Blocks: 2 IO Block: 4096 regular file
Device: 804h/2052d Inode: 10208 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-03-13 13:17:31.980325600 +0000
Modify: 2019-03-13 13:14:11.690160100 +0000
Change: 2019-03-13 13:14:11.690160100 +0000
Birth: -
And when I run:
~$ head -n 1 /media/storage/ss/script.py
Output:
#! /usr/bin/env python
And when I run:
mount | grep /media/storage
Output:
/dev/sda4 on /media/storage type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,allow_other,blksize=4096,user)
Thanks!
Best Answer
You've mounted
/media/storage
asnoexec
.noexec
does not allow executing any binaries on the mounted file system (seeman 8 mount
).You have to specify
exec
as mount option in yourfstab
. Note that yourfstab
entry is also missing thedefaults
option (see alsoman 5 fstab
). You probably want something akin toCheck
man 5 fstab
orman 8 mount
for the meaning ofdefaults
. At least on my system, it's the same asbut that depends on the file system.
If you want to check this without changing your
fstab
, tryfirst to remount
/media/storage/
with executable permissions and check your script again.