0

First of all, there are many questions like this on AU. Still, none of them solved my problem.

I've compiled my C source using cc test.c, and it did generate a.out file.

However when I run it I get this error -

bash: ./a.out: Permission denied

My source is not in the home directory, it is on different FAT-32 partition, so I've mounted the drive in which the code is using the following command -

$ udisks --mount /dev/sda7 --mount-options umask=022
Mounted /org/freedesktop/UDisks/devices/sda7 at /media/48E9-FD53
$ cd /media/48E9-FD53/C

Then I compile my code using cc

I've also tried gcc. But still I get the same error.

Then I did - chmod +x a.out, still the same problem. Also with(chmod 755 a.out) and chmod u+x a.out.

I've also tried compiling and executing the program using sudo.

I've also tried - sudo chown sannidhya:sannidhya a.out.

I've tried every thing that I found on AU, still couldn't get it to work.

How can I run .out file (without moving it to home directory)?

Note - I am using Ubuntu 12.04 LTS.

But a weird thing here is, even after running chmod +x a.out, on running - ls -l a.out, I get-

-rw-r--r-- 1

also when I check the properties of a.out, under Permissions tab, there are only 2 modes available Read only and Read and Write.

2
  • Check you mount options with e.g. calling mount from command line without any further options. I assume the no exec bit is set – frlan Apr 13 '17 at 12:30
  • Run strace a.out and post output either here or on paste.ubuntu.com and provide link – Sergiy Kolodyazhnyy Nov 30 '17 at 23:40
1

If you copy the binary off of the FAT32 filesystem and onto your native ext* filesystem, the binary should run, when given the right permissions (+x).

It is possible that a filesystem is mounted with no execution rights. So in addition to chmod, you will want to also check your filesystems' mount options.

2
  • I've mounted my partition using - udisks --mount /dev/sda7 --mount-options umask=022... – ShuklaSannidhya Apr 17 '13 at 16:20
  • Have you tried copying the binary you compiled onto a different filesytem to attempt to run it? – Wing Tang Wong Apr 17 '13 at 19:01

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.