0

This question already has an answer here:

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

running ./a.out:

bash: ./a.out: Permission denied

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

 sudo: ./a.out: command not found

marked as duplicate by muru, Rinzwind, Mark Kirby, Fabby, Pilot6 Jan 10 '16 at 9:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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
1

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.

0

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.

  • 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.