Cant ./file.sh but can sh file.sh

I chmoded the file and can’t ./file.sh but sh file.sh and bash file.sh both work… Any ideas?

What OS?

chmod +x file.sh didn’t work?

Do you have a shebang on the first line?

#!/bin/bash or the likes?

1 Like

Is the file on a noexec volume? I.e. vfat/exfat ones or thumbdrives in general tend to automount as noexec.

You can see this with mount command.

3 Likes

This is what it is.

sh instead of bash.

popos.

Got it working. whatever the issue was, i mounted it (auto) via disks utility and not command line in fstab. Maybe just the restart fixed it. idk.

1 Like

That’s strange. Must have been mounted with noexec flag.

Gnome has some strange visions…

2 Likes

properties were defaults.

Sounds like good security practice to me. Executables should be in your base OS disk, not on external media, 99.999% of the time in 2021.

So home directories for users?