Unable to execute script file with +x permission, even with sudo

18,583

The file system was mounted with noexec which prevented executing files.

Share:
18,583

Related videos on Youtube

user1539179
Author by

user1539179

Updated on June 14, 2022

Comments

  • user1539179
    user1539179 over 1 year

    I am unable to run scripts from a mounted partition. I have created a basic "Hello World" script that will execute from my home directory fine, but when I move it to the mounted partition, I am unable to execute the file.

    $ ls -l
    -rwxr-xr-x  1 user user    31 Mar  4 21:33 test.sh
    $ ./test.sh
    -bash: ./test.sh: Permission denied
    $ sudo ./test.sh
    [sudo] password for user:
    sudo: unable to execute ./test.sh: Permission denied
    $ cd ..
    $ ls -l
    drwxrwxrwx  6 user root  4096 Mar  4 21:34 sda5
    

    I have no idea what to do.

    ETA: I am able to use "bash test.sh" to execute the file, just not ./test.sh. I am able to do ./test.sh in the home directory.

    • John Colanduoni
      John Colanduoni over 10 years
      What filesystem is the mounted partition?
    • hek2mgl
      hek2mgl over 10 years
      type mount in your terminal. Search the output for the partition where test.sh is located. Mounting flags are at the end of the line in () brackets. Do you see the noexec there? (likely)
    • user1539179
      user1539179
      /dev/sda5 on /media/sda5 type ext4 (rw,noexec,nosuid,nodev) It looks like you're right
  • James
    James over 5 years
    I'm using the 'Disks' tool on Ubuntu (via the GUI) and was able to simply add the exec option. That seems to of prevented the noexec which is automatically added when the user option is used. And now I can run the file as desired.