cd /media/k4li/data2/C
gcc program.c

running ./a.out:

bash: ./a.out: Permission denied

if I enter sudo ./a.out i get:

 sudo: ./a.out: command not found
  • Is this partition NTFS? – muru Jan 9 '16 at 20:36
  • yes, data2 is ntfs – Kali Jan 9 '16 at 20:38
  • Besides that: if you use Kali as your name might suggest you need to use U&L for your questions ;) – Rinzwind Jan 9 '16 at 20:49

Because NTFS doesn't store or use "Linux" file permissions the kernel emulates them. You set the entire mount partitions permissions at mount time. You have two option.

  1. Remount the NTFS partition, setting the permissions to something less restrictive. This is the least secure option.

  2. Move the executable to your Linux partition, then chmod it, then run it. There are more steps here but this is the most secure option.

2 is more secure then 1 because you only change the permissions of one file, not the entire partition.

| improve this answer | |

You need to set a.out's permissions to executable - use:

sudo chmod +x a.out

And then try running it again.

Edit: Need to use sudo on chmod.

| improve this answer | |
  • 2
    No he does not need sudo. He needs executable permission on the disk. NTFS is not Linux. – Rinzwind Jan 9 '16 at 20:48

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