2

I use a mobile hard disk in ubuntu and I want to run scripts on the disk. At first, the permission is denied. Therefore, I followed the advices in this answer How do I use 'chmod' on an NTFS (or FAT32) partition? and use

sudo mount -t ntfs -o rw,auto,user,fmask=0022,dmask=0000,uid=scw4750,gid=scw4750 /dev/sdf1 /media/Elements

to remount the disk.

After this the permission becomes:

-rwxr-xr-x 1 scw4750 scw4750 32  6月  1 14:45 test.sh*

However, when I run test.sh with >>./test.sh

It returns:

bash: ./test.sh: Permission denied

Why do this happens? How to solve it? Thanks.

3
  • You can run any bash script (executable or not) with bash scriptname.sh
    – user423626
    Jun 1, 2016 at 7:54
  • Thanks @BharadwajRaju, I tried and it works. But how can I run with ./test.sh?
    – Liang Xiao
    Jun 1, 2016 at 8:08
  • That will have to be answered by someone else, but it looks like you are with rw permissions, only read-write — not execute.
    – user423626
    Jun 1, 2016 at 8:09

1 Answer 1

2

As noted in the mount manpage, the user mount option implicitly turns on the noexec option as well

user   Allow an ordinary user to mount the filesystem.  The name of the
       mounting user is written to mtab so  that  he  can  unmount  the
       filesystem  again.   This  option  implies  the  options noexec,
       nosuid, and nodev (unless overridden by subsequent  options,  as
       in the option line user,exec,dev,suid).

where

noexec Do  not  allow  direct  execution of any binaries on the mounted
       filesystem. 
3
  • Then what should I do? @steeldriver
    – Liang Xiao
    Jun 1, 2016 at 11:48
  • 1
    Like the manpage says, either remove the user option from your mount command or add an explicit exec option AFTER the user option. Since you're mounting using sudo, the first solution probably makes most sense. Jun 1, 2016 at 12:28
  • I don't understand how this answer doesn't appear in the search for noexec related issues and this site has had two related questions that I have seen in the past few days ... Probably it should be upvoted more.
    – Raffa
    Aug 5, 2023 at 13:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .