Android 5

Termux 0.54

Not rooted, no wish to

$ pwd
$ id
uid=10096(u0_a96) gid=10096(u0_a96) groups=1015(sdcard_rw),1028(sdcard_r),3003(inet),9997(everybody),50096(all_a96)
$ ls -l python
total 0
$ ls -dl python
drwxrwx---    2 root     sdcard_r     32768 Sep 23 22:10 python

So according to permissions, I should be able to write to the python folder. But creating a file gives permission denied.

I have seen the platform.xml solution but can't edit the file.

I would like to write to card then easy to move card and files between machines.

Regards John

  • Maybe it has something to do with SELinux. What does ls -ld /storage/sdcard1/ show though? Also have you enabled the storage permission in the app settings of Termux? – Tom Yan Sep 24 '17 at 14:12
  • This is something Google is to blame. From Android 5 onwards, there have been even more restrictions placed on the external SD. Apps are now expected to make use of a so-called DocumentProvider interface, as to ask the user for the permission to operate on the SD card. As you may infer by the above, there is no way to manually grant this permission if it is not requested, but to have root privileges and install Xposed, or to have a custom recovery, init.d support and flash a .zip to allow SD card access to any app. – Death Mask Salesman Sep 24 '17 at 19:21
  • @TomYan Sadly, as you can see from my answer here, the Storage permission only affects /storage/emulated/0 (/storage/sdcard0 on Lollipop). – Death Mask Salesman Sep 24 '17 at 19:32

Use termux-setup-storage to setup your storage. See https://wiki.termux.com/wiki/Termux-setup-storage for instructions and more information. Write data will be enabled in the Termux private folder on external storage through ~/storage/external which is a link to Android/data/com.termux/files/ on your external SD card.

  • This is for android 6. As I mentioned, I have android 5. – JohnN Dec 11 '17 at 12:42

It tells you "permission denied" because termux requires su access to grant access. Since your device isn't rooted them its obvious you can't gain su access. The python command is stored in the root storage and the command you wrote can't access python as a normal user

  • -1 because: 1) Termux has its own Python; never did Python reside in the /system partition, hence root has nothing to do with it, and 2) nowhere in the question did OP call the Python interpreter. – Death Mask Salesman Sep 24 '17 at 19:18
  • ...and ty for the downvote mr. professor – Beveloper Sep 25 '17 at 5:54
  • The folder is called python. It could be called anything. – JohnN Sep 25 '17 at 12:58
  • Also, the permissions on termux are "modify or delete contents of sd card and read contents of sd card". So this does not include create? – JohnN Sep 25 '17 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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