Shell - write file to external storage - permission denied

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Lee321987
Junior Member
Junior Member
Posts: 10
Joined: 2021-12-10, 21:44 UTC

Shell - write file to external storage - permission denied

Post by *Lee321987 »

Hello.
Is there any way to allow a shell command to write files to external storage?
I have a button that runs this command:

Code: Select all

sh ls > filelist.txt
It works on internal storage, but on external storage I get "permission denied" in every dir except:
/Android/data/com.ghisler.android.TotalCommander

I am not rooted.
Running Android version 7.
Total Commander has been granted "Storage" permission in Android settings.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Shell - write file to external storage - permission denied

Post by *ghisler(Author) »

On Android 11 and newer, all folders under /Android/data are restricted to the respective app. The Total Commander app internal name is com.ghisler.android.TotalCommander, so its access is restricted to /storage/emulated/0/Android/data/com.ghisler.android.TotalCommander.

The folders of other apps can only be accessed via virtual folders (scoped storage) which isn't available via shell commands.
I recommend putting the files in /Android/media instead, they are the public folders of an app now.
Author of Total Commander
https://www.ghisler.com
Post Reply