Executable files won't execute

Why will an executable file work normally when residing on one drive but not work when placed an another?

Leap 15.3
Desktop computer with 4 SSD hard drives

sda is presently Windows
sdb is the Leap boot drive with swap, root and home
sdc is a data drive with three partitions mounted in my home directory: Videos, Pictures and Spare-0
sdd is a data drive with four partitions mounted in my home directory: Models, Develop, Spare-1 and Spare-2

They are mounted at boot by way of an entry in /etc/fstab

UUID=789d248e-9a13-47a5-b6a9-578b1d7efd0d  /home/bart/Videos         ext4  nofail,users,data=ordered      0  0

All this is working properly or at least the way I expected it to.

I am trying to write a bash script and am using the Develop directory while getting it up and working. pwd = ~/Develop.
I created a “Hello World!” script, in the Develop directory, named it test and tested it with the command: bash test. It worked.
I then did a chmod +x test and tried to run it using ./test and received this result

bart@ASU-X99:~/Develop> ./test 
bash: ./test: Permission denied

So, I did su -, changed to /home/bart/Develop and tried it again as root and got the same error.

After much time spend trying to understand why root didn’t have permissions enough I came to the conclusion that it wasn’t root or my user that didn’t have permissions, it was/is bash. Can this be right?

I found that if the file test was placed in any directory on sdb (of course not EUFI or swap) it would run.
If the file test was placed in any directory of either sdc or sdd it would not run.

I am having trouble coming up with a reason why this would be considered acceptable behavior. Is it in fact, the way it’s supposed to be? If so, why? Or, is there something wrong with my system? What could it be?


Hard to know without more information.

If the file system is mounted with “noexec”, that would explain the problem. If this is a USB device, it might default to using “noexec”.

You should still be able to run it with:

 bash ./test

By the way, using the name “test” might be a bad idea, because there is a builtin “test”.

Did you add the whole shebang in the test script as the first line?


I think you found it! !!!

As you can see from my post, the only options I entered were:
nofail - so the computer will still boot if a drive is unavailable.
users - so I, as a normal user can mount and unmount a drive.
data=ordered- which I understand is recommended for ssd.

However, while reading the man page for mount, I came across mention of /etc/mtab, which I admit I didn’t know existed. So, a quick cat of that file shows all the drives mounted with noexec in the string. Here’s an example of one partition (They are all the same)

/dev/sdc2 /home/bart/Pictures ext4 rw,nosuid,nodev,noexec,relatime,data=ordered 0 0

noexec must be a default entry that is added because I didn’t over-ride it. That’s obviously my answer as to why I couldn’t execute the file! (hurray!)

Now… What is the reason the system insisted it be put in there?
What are the ramifications of over-riding this default?
And, if I decide to do so, how do I do it?


P.S. The file was actually named junk. I just didn’t think it would look “professional” My rule is that anything on my system named junk.* may be removed without checking. Makes cleanup much easier.

I think Malcolm is on the write track, check the permissions on the file and on the directory.

If a user can just plug in a USB drive that happens to have executable malware then you might have a problem. So for mounting such drives “noexec” and “nosuid” are defaults to minimize the risk.

What are the ramifications of over-riding this default?

If you have vetted the drive and know it is safe, then that should not be a problem.

And, if I decide to do so, how do I do it?

Again, I don’t know how you are mounting this. If you mount with a manual mount command, then:

mount -o exec /dev/whatever /mount/point

(modify as needed).

P.S. The file was actually named junk.

In that case, the file name was not a problem.

Show the output of the following command:

**i3-4130:~ #** mount | grep noexec 
proc on /proc type proc (rw,nosuid,nodev,**noexec**,relatime) 
sysfs on /sys type sysfs (rw,nosuid,nodev,**noexec**,relatime) 
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,**noexec**,relatime) 
devpts on /dev/pts type devpts (rw,nosuid,**noexec**,relatime,gid=5,mode=620,ptmxmode=000) 
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,**noexec**,relatime,nsdelegate,memory_recursiveprot) 
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,**noexec**,relatime) 
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,**noexec**,relatime) 
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,**noexec**,relatime,mode=700) 
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,**noexec**,relatime) 
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,**noexec**,relatime) 
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,**noexec**,relatime) 
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,**noexec**,relatime) 
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,**noexec**,relatime) 
**i3-4130:~ #** 

The command will not run when residing on a partition mounted with option noexec.

NOPE. With Tumbleweed noexec is triggered when selecting option user:

**erlangen:~ #** grep -e WD25 -e FR735 /etc/fstab  
LABEL=**FR735**                                /**FR735**                  vfat   **user**,noauto,                  0  0 
UUID=2f0030b8-7257-4cba-be3e-b33154cda052  /**WD25**                   ext4   noauto                        0  0 
**erlangen:~ #**
[FONT=monospace]**erlangen:~ #** mount |  grep -e WD25 -e FR735  
/dev/sde1 on /**WD25** type ext4 (rw,relatime) 
/dev/sdd on /**FR735** type vfat (rw,nosuid,nodev,**noexec**,relatime,uid=1000,gid=100,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro,user=karl) 
**erlangen:~ #**[/FONT]

I now understand.

The exec option is shown in man as being the default.
When I added the users option in fstab, that triggered the noexec for that filesystem.
I can, if I want, over-ride it in fstab by adding exec to the options line.
The reason it’s there is for security against malware when allowing a user to mount a filesystem.

Thank you all so very much for your help!


Your are welcome. Thanks for the feedback.

The hotstar platforms allow users to watch live sports streaming, TV series, news, movies, sports, and more with a wide variety of genres and languages. Hotstar is available on almost every massive platform. https://hotstarapp.live/