Termux runs in its own private folder, so the first time you try to read a download, copy a photo or clone a repo into your phone’s shared storage, you’ll often hit Permission denied. That Termux permission denied error is Android doing its job, not Termux being broken. The fix is usually one command plus a permission toggle, but there are a few cases where no permission will help. This guide covers both.
Why Termux can’t see your files by default
Every Android app gets its own sandboxed data directory. For Termux that’s where your home folder lives, at /data/data/com.termux/files/home. Anything outside it, including /sdcard and the Download folder, needs a storage permission that Termux doesn’t ask for until you tell it to. Until then, commands like this fail:
$ ls /sdcard/Download
ls: cannot open directory '/sdcard/Download': Permission denied
Step 1: run termux-setup-storage
The proper fix is the built-in setup command:
termux-setup-storage
Android shows a permission prompt. Accept it. Termux then creates a ~/storage folder in your home directory, full of shortcuts into shared storage. The one you’ll use most is ~/storage/shared, which is the root of your internal storage, with your Download, DCIM, Pictures and Documents folders inside. There are also direct shortcuts such as ~/storage/downloads and ~/storage/dcim, and one for an SD card if you have one.
ls ~/storage
ls ~/storage/shared/Download
If ~/storage already exists, the command warns that it will rebuild the folder and asks you to confirm. That only recreates the shortcuts. Your actual files aren’t touched.
Step 2: grant the permission manually if the prompt never appeared
If you tapped Deny once, Android may stop showing the prompt and the command quietly does nothing useful. On recent Android versions Termux needs All files access, which you can grant yourself:
- Open Android Settings
- Search for All files access, or go to Apps > Special app access > All files access (the exact path varies by phone maker)
- Find Termux and turn it on
- Go back to Termux and run
termux-setup-storageagain
On older Android versions the same permission appears as Files and media or Storage under Settings > Apps > Termux > Permissions. If it’s already on, turn it off and on again, then rerun the command.
Step 3: check you haven’t mixed Termux installs
Termux and its add-ons (Termux:API, Termux:Widget, Termux:Styling and so on) must all come from the same source, because they’re signed with the same key and share permissions. If you installed Termux from F-Droid and an add-on from somewhere else, or the other way round, things break in confusing ways, including storage and API commands failing.
Pick one source, uninstall the mismatched apps, and reinstall them all from it. Back up anything in your home folder first, because uninstalling Termux deletes it. If you’re setting Termux up for development work, Claude Code in Termux on Android covers a clean install end to end.
Permission denied when running a script from storage
This one catches a lot of people. You copy a script to ~/storage/shared, make it executable, and still get Permission denied when you run it:
$ chmod +x ~/storage/shared/test.sh
$ ~/storage/shared/test.sh
bash: /data/data/com.termux/files/home/storage/shared/test.sh: Permission denied
Android mounts shared storage with the noexec option, so nothing stored there can be executed directly, and chmod has no effect. No permission setting changes that. You have two options:
- Run it through the interpreter instead:
bash ~/storage/shared/test.shorpython ~/storage/shared/script.py - Better, copy it into your Termux home, where execution works normally:
cp ~/storage/shared/test.sh ~/ && chmod +x ~/test.sh
The same applies to compiled binaries and anything you build. Keep code, virtual environments and Git repositories in your Termux home, and use shared storage only for files you want to move in and out of the phone.
Git complains about dubious ownership
If you clone a repository into shared storage, Git may refuse to work in it with a detected dubious ownership in repository error. That’s because files in shared storage aren’t owned by the Termux user. You can tell Git to trust one specific path:
git config --global --add safe.directory /storage/emulated/0/projects/myrepo
But the cleaner fix is the same as above: clone into ~/ instead. Shared storage also doesn’t support symlinks or Unix permissions properly, so many repos and build tools behave oddly there. If you push and pull over SSH, SSH in Termux shows how to set up keys in your home folder.
Folders no permission will unlock
Some locations are off limits to every normal app on modern Android, Termux included:
Android/dataandAndroid/obbinside shared storage, where other apps keep their files- Other apps’ private directories under
/data/data - System folders that need root to write to
Without root there’s no workaround for these, so if a guide tells you to edit another app’s files from Termux, it assumes a rooted phone.
Quick checklist
- Run
termux-setup-storageand accept the prompt - If no prompt appears, grant All files access to Termux in Android settings and run it again
- Make sure Termux and every add-on come from the same source
- Don’t run scripts or keep repos in shared storage; copy them to
~/ - Accept that
Android/datais off limits without root
Once storage works, Termux becomes a proper Linux workbench on your phone. Running OpenCode in Termux is a good next project.

Leave a Reply
You must be logged in to post a comment.