+ 8
permission denied in Termux
when i compile c++ and try to run a.out ./a.out it prints "permission denied" how can I fix this?
32 Réponses
+ 5
chmod +x a.out
./a.out
+ 3
Slick how can i check permissions?
i just want to execute a simple c++ program.
Note: when i compile using clang command it prints linker error and when i compile using g++ command it generates a.out file.
+ 3
Mehran then try:
sudo su
./a.out
First you will be root (you have 100% permission).
Then run the binary file.
+ 3
permission denied again.
بی خیالش
ignore it....
+ 3
Mehran the command that Reynard gave just makes the internal/external storage of the phone accessible to termux. And termux's data dir is very well accessible within termux and it allows to set all those basic permissions which you could setup on Linux.
+ 3
Mehran secondly if you wanna use chmod +x you'll have to place those files under termux data dir
+ 2
#when you're in the directory:
type: ls -l
#check permissions
# also, what does the code do? You can't mess with certain things unless your phone is rooted
+ 2
Try this.
sudo ./a.out
+ 2
Mani_K_A
it prints:
No superuser binary detected.
Are you rooted?
my phone isn't rooted.
+ 2
Mani_K_A trying to run sudo with any arg prints the previous message.
+ 2
Mehran Try this:
chmod 777 a.out
Or
chown your_username:your_username a.out
It might work🤷🏻♂️
+ 2
ای بابا
+ 2
Mehran you can make files executable by using chmod +x command. But please note on non-rooted Android devices this can be only achieved within the /data/data/com.termux/files/ directory. You can't make files on the Internal/External Storage executable as those mount-points (i.e. /storage & /sdcard ) have only rw permissions to apps & the user (i.e. you)
+ 2
P Jain. are you sure?
as you can see in Reynard's answer he says i have no problem so there's no need to place files in unavailable directories such as internal storage of the app.
+ 2
Mehran what P Jain said is true,try running pwd in termux and verify if the output is /data/data/com.termux/files/home
But technically it wouldnt be anywhere else since your device is not rooted and /data/data/com.termux/files will be the first directory that youre accessing when installing termux,unless there was some kind of corruption in the installation, you might want to reinstall termux and try again.
+ 2
So what do you mean my device should be rooted?
Mehran no what I mean is that if you want full control over your device (like executing chmod +x in internal Storage, using tsudo/tsu from termux) then root but from what I see that if you only want to make a file executable then no need to root, copy that file to $HOME in termux and then run chmod +x on it
+ 2
mv a.out ~
cd ~
chmod +x a.out
./a.out
run file in root directory
+ 1
Slick
thank you.
but the problem could not be solved.
it prints again "permission denied"
+ 1
Mehran what are you compiling it with? Do "g++ filename -o outputname" then run it ./outputname
+ 1
raynard I tried it before.
prints same result.