Give Termux Access to Shared Storage With termux-setup-storage
By default Termux cannot see your phone’s shared folders (Downloads, Photos, DCIM). termux-setup-storage asks Android for permission and creates handy links under ~/storage/. This is a deep dive—Medium only because Android 11+ permission quirks show up often.
What You Need
- F-Droid Termux open.
- Willingness to grant Files and media / storage access when Android prompts.
Grant storage and explore ~/storage
Step 1: Run termux-setup-storage
termux-setup-storage
Built into Termux—no separate
pkg installfor this command. Android should show a permission dialog; tap Allow.Step 2: Confirm the symlink folder
ls -la ~/storage
Typical links (names can vary slightly by Android version):
shared— shared storage root (often /sdcard)downloads— Downloadsdcim— camera / DCIMpictures,music,movies— media folders
Step 3: Browse and copy a file
cd ~/storage/downloads pwd ls cd ~ echo "hello from termux" > ~/note-from-termux.txt cp ~/note-from-termux.txt ~/storage/downloads/ ls ~/storage/downloads/note-from-termux.txt
Open the Files app → Downloads: you should see note-from-termux.txt. Import works the other way:
cp ~/storage/downloads/some.pdf ~/.Step 4: Android 11+ “Permission denied”
If
ls ~/storage/sharedfails after you thought you allowed access:- Open system Settings → Apps → Termux → Permissions.
- Revoke Files and media / Storage, then grant it again (on some builds choose Allow management of all files if offered).
- Return to Termux and re-run
termux-setup-storage.
Step 5: Re-run safely
Running
termux-setup-storageagain is fine—it recreates the symlinks if missing. If~/storagenever appears, fix permissions (step 4) first.
Official docs
- termux-setup-storage: wiki.termux.com/wiki/Termux-setup-storage
- Internal and external storage: wiki.termux.com/wiki/Internal_and_external_storage