Permission denied termux что делать
Перейти к содержимому

Permission denied termux что делать

  • автор:

No permissions for Termux to access internal storage — even for reading

Using the termux (https://termux.com) terminal-emulation program, I type the following command:

ls /sdcard 

I get the following error:

ls: can't open '/sdcard': Permission denied 

Realizing that the /sdcard directory on Android is a symlink, I tried to find the location of the actual directory — learning that it is not just a symlink, but a symlink to another symlink, and the actual directory is /storage/emulated/0 So finally, I typed:

ls -ld /storage/emulated/0 

The result I got was:

drwxrwx--x 63 root sdcard_r 4096 Aug 10 12:04 /storage/emulated/0 

So in short — I don’t know whether termux used to run with the permissions of the sdcard_r group or whether the o permissions used to allow read-write — but I need to know which of the two it used to be and how to fix things — because being able to access the contents of the internal SD card is kinda critical. No, my device is not rooted, nor do I plan to root it — so I can not give any information that I’d have to root the device to obtain. However, not being rooted never in the past prevented me from having read access to the /sdcard directory — so this is new (and disturbing). Granted — it’s been a few months since previously I tried to do this — but this new limitation from Android seriously hampers the usability of termux and who-knows-what-else — as I need to be able to have access to files that are on my SD Card. (I can still do a lot, even if not everything, even without write permissions — but am pretty much stuck in the water if I can’t get read permissions, as is presently the case.)

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?

7th Sep 2021, 2:28 AM
32 Answer s
chmod +x a.out ./a.out
7th Sep 2021, 2:52 AM

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.

7th Sep 2021, 3:43 AM

Mehran then try: sudo su ./a.out First you will be root (you have 100% permission). Then run the binary file.

7th Sep 2021, 5:07 AM
permission denied again. بی خیالش ignore it.
7th Sep 2021, 7:17 AM

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.

8th Sep 2021, 5:07 AM
Mehran secondly if you wanna use chmod +x you’ll have to place those files under termux data dir
8th Sep 2021, 5:11 AM

#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

7th Sep 2021, 3:06 AM
Try this. sudo ./a.out
7th Sep 2021, 4:55 AM
Mani_K_A it prints: No superuser binary detected. Are you rooted? my phone isn’t rooted.
7th Sep 2021, 5:04 AM
Mani_K_A trying to run sudo with any arg prints the previous message.
7th Sep 2021, 5:45 AM
Mehran Try this: chmod 777 a.out Or chown your_username:your_username a.out It might work����‍♂️
7th Sep 2021, 6:51 AM
7th Sep 2021, 7:17 AM

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)

8th Sep 2021, 4:34 AM

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.

8th Sep 2021, 5:04 AM

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.

8th Sep 2021, 5:23 AM

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

8th Sep 2021, 5:35 AM
mv a.out ~ cd ~ chmod +x a.out ./a.out run file in root directory
7th Jan 2022, 11:36 AM
Ishaan Kapoor
Slick thank you. but the problem could not be solved. it prints again «permission denied»
7th Sep 2021, 3:04 AM
Mehran what are you compiling it with? Do «g++ filename -o outputname» then run it ./outputname
7th Sep 2021, 8:00 AM
raynard I tried it before. prints same result.
7th Sep 2021, 8:19 AM

Often have questions like this?

Learn more efficiently, for free:

Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

giampaolo / psutil Public

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Termux] PermissionError: [Errno 13] Permission denied: ‘/proc/stat’ #2195

babaric-dev opened this issue Jan 23, 2023 · 11 comments

[Termux] PermissionError: [Errno 13] Permission denied: ‘/proc/stat’ #2195

babaric-dev opened this issue Jan 23, 2023 · 11 comments

Comments

babaric-dev commented Jan 23, 2023 •

Summary

  • OS: Android 10
  • Architecture: aarch64
  • Psutil version: 5.9.4
  • Python version: 3.11.1
  • Type: core

Description

>>> import psutil Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_common.py", line 399, in wrapper return cache[key] ~~~~~^^^^^ KeyError: (('/proc',), frozenset()) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_pslinux.py", line 285, in set_scputimes_ntuple("/proc") File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_common.py", line 401, in wrapper ret = cache[key] = fun(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_pslinux.py", line 268, in set_scputimes_ntuple with open_binary('%s/stat' % procfs_path) as f: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_common.py", line 728, in open_binary return open(fname, "rb", buffering=FILE_READ_BUFFER_SIZE) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PermissionError: [Errno 13] Permission denied: '/proc/stat' >>> 

From the error message above, 2 errors occured:

  1. KeyError (IDK why this appears)
  2. PermissionError (because of SeLinux restrictions on Android)

I want to focus on more about the second error. Because we never know which files are readable and which are not, we should handle exceptions raised by open() . We should add an try-except clause catching PermissionError . Another solution that I propose is to check whether the file is readable first before actually reading it. Both have their pros and cons, but I prefer the latter solution.

The text was updated successfully, but these errors were encountered:

In termux android ls: cannot open directory ‘.’: Permission denied?

If you’re running Android 11+, you don’t have unrestricted access to the android/data directory in shared storage and termux can’t grant that access.

Aug 5, 2022 at 4:14
Please provide enough code so others can better understand or reproduce the problem.
Aug 5, 2022 at 19:50

Please edit your question to include your errors and code as text rather than as screenshot(s). On stack overflow images should not be used for textual content, see Discourage screenshots of code and/or errors and Why not upload images of code on SO when asking a question for why. For instructions on formatting see How do I format my code blocks?. A minimal reproducible example showing what you have tried that did not work would maximize your chances of getting help. See How to Ask.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *