I have a python script, in which I have the following shebang #!/usr/bin/python the script permissions are -rwxrwxrwx. 1 user user 709 script.py the owner of the script is the same as the user I use to run the script.

I do not understand why I get Permission denied when I run ./script.py but I can run it with python script.py or /usr/bin/python script.py. What I am missing?

Linux distribution is RedHat 6

  • 1
    Which distribution are you using? E.g. on Fedora it could theoretically be a SELinux issue. – sourcejedi Jul 31 '19 at 21:50
  • 7
    vol mounted with noexec ? – steve Jul 31 '19 at 21:56
  • I was having this same issue until I made the file executable. Are you 100% sure that you have the executable bit on? chmod u+x script.py – Gordster Jul 31 '19 at 22:03
  • you could try using strace -f on the shell, then try to run the script, and see where you get the error – mmusante Aug 1 '19 at 1:03
  • 1
    @steve you are right /dev/mapper/systemvg-home on /home type ext4 (rw,noexec,nosuid,nodev). Thank you. – dejdej Aug 1 '19 at 6:33

The file-system where the script resides was mounted with 'NOEXEC' flag /dev/mapper/systemvg-home on /home type ext4 (rw,noexec,nosuid,nodev)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.