PDA

View Full Version : Permission denied when trying to run compiled C file in Nethunter terminal Nexus 6



Echo
2016-02-09, 08:50
I've successfully installed Nethunter on my Nexus 6. I compiled the helloword program that was written in C with the following command: gcc helloworld.c -o helloworld
It compiled just fine. But when i try to run it in the Nethunter terminal using: ./helloworld , it gives me permission denied.
I tried all sorts of chmod and sudo but it still doesn't work.
I also tried ls -l helloworld and it gives me: rw-rw---- , there are no x.
How can I make this program run? It's driving me nuts!

Bob The Marauder
2016-02-18, 15:28
What kinds of chmod commands did you try? Do these two make any difference?


chmod +x helloworld
chmod 750 helloworld

Is there any possibility that your chmod command and ls command are acting on different files? e.g.


root@kali/~>chmod +x helloworld.c
root@kali/~>ls -l helloworld

would cause the situation you have now as the file whose permissions you are changing is not the one you are checking the permissions of (not that I haven't wasted hours in the past with similar typos at all, compounded by the convenience of recalling previous commands rather than actually typing them).

Sorry it's not really a solution but might help you step back and have an aha moment.

Itachi Uchiha
2017-09-24, 16:06
I know this is a late reply......but this might be useful to someone else
First create your c program in some directory like /sdcard/
Then go to Nethunter Terminal and go to the directory
Then move the file to the root directory of Nethunter using the command
root@kali:mv filename.c /filename.c
Now compile the program
root@kali:gcc filename.c
Now change the permissions of a.out
root@kali:chmod +x a.out
Now run your program
root@kali:./a.out
😉
The thing you have to understand is that the root directory of your phone is different from the root directory of your Nethunter