How to Fix Termux Storage Permission Denied Error
How to Fix Termux Storage Permission Denied Error
If you are a Linux enthusiast or developer running command-line tools on Android, Termux is an indispensable terminal emulator. However, one of the most frustrating obstacles new and experienced users encounter is the notorious "Permission denied" error when attempting to access local files, write to shared storage, or save scripts to the internal memory.
By default, Android isolates Termux inside its own sandboxed environment. Without proper explicit access, commands like ls /sdcard, cp script.py /sdcard/Download/, or writing output files to shared folders will immediately trigger a storage error. In this comprehensive guide, we will walk you through fixing the termux storage permission issue step-by-step, including advanced troubleshooting when standard commands fail on modern Android versions.
Why Does the Termux Storage Permission Error Occur?
Understanding why this error happens makes it much easier to prevent in the future. Android enforces strict security boundaries known as sandboxing and Scoped Storage. Termux operates inside its own isolated app container (located at /data/data/com.termux/files/usr).
The primary reasons you encounter permission errors include:
- Missing Storage Symlinks: Termux has not been granted access to create symlinks targeting Android's shared internal directories (such as Downloads, Pictures, and Music).
- Android OS Permission Denial: Android system settings have restricted Termux from accessing "Files and media."
- Outdated Google Play Build: The version of Termux hosted on the Google Play Store was deprecated in 2020 due to SDK targeting limitations. It cannot properly negotiate storage access on Android 10, 11, 12, 13, or 14.
- Scoped Storage Restrictions: Newer Android updates restrict direct block-level file access to external SD cards and root system paths.
Step-by-Step Fix: Standard Storage Permission Setup
The primary tool built into Termux to manage shared storage access is the termux-setup-storage utility script. This command handles two main tasks: it requests Android system permissions and creates convenient symlinks inside the ~/storage directory.
Step 1: Execute the Setup Storage Command
Open your Termux terminal and type the following command precisely:
termux-setup-storage
Step 2: Grant Android OS Access
As soon as you execute the command, an Android system pop-up dialog will appear asking: "Allow Termux to access photos, media, and files on your device?"
Tap Allow. On Android 11 and newer devices, you may be redirected to an Android system settings page labeled All files access. Toggle the switch next to Termux to the ON position.
Step 3: Verify Symlink Creation
Once permission is granted, Termux creates a folder called storage in your home directory containing symlinks to primary shared locations. Verify the setup by listing the contents of your home directory:
ls -la ~/storage
You should see folders linking directly to device storage:
~/storage/shared-> Internal device storage root (/sdcard)~/storage/downloads-> Your Download directory~/storage/dcim-> Digital Camera Images~/storage/pictures-> Pictures folder~/storage/music-> Audio files directory~/storage/movies-> Video media directory~/storage/external-1-> External micro-SD card (if inserted and supported)
Troubleshooting: termux-setup-storage Not Working Fix
What happens if running termux-setup-storage simply hangs, prints an error message, or fails to trigger the system permission popup? If you are facing a situation where the built-in script fails, apply this tested termux-setup-storage not working fix guide.
Fix 1: Upgrade to the Official F-Droid / GitHub Build
The most common cause for termux-setup-storage failing completely is using the outdated Google Play Store build. The Play Store version cannot request proper storage privileges on Android 10 and above.
- Uninstall your current Termux application from your Android device.
- Download and install the latest Termux APK directly from F-Droid or the official Termux GitHub Releases repository.
- Re-open Termux and execute
termux-setup-storageagain.
Fix 2: Manually Grant Files and Media Permission in Android Settings
If the pop-up dialog never appears, you can force-grant the necessary termux storage permission directly through Android Application Management:
- Open your Android phone's Settings app.
- Navigate to Apps or Application Manager.
- Locate and select Termux from the app list.
- Tap on Permissions.
- Select Files and media (or Storage depending on your Android version).
- Change the setting from Don't allow to Allow management of all files (or Allow access to media only).
After manually adjusting these settings, return to your terminal, close the session using the exit command, re-open Termux, and execute:
mkdir -p ~/storage && termux-setup-storage
Terminal Output Verification
To confirm that your storage configuration is fully operational, try writing a test file to your Android Downloads directory from inside Termux.
cd ~/storage/downloads
echo "Termux Storage Fix Successful" > test_fix.txt
cat test_fix.txt
Below is an example of what successful terminal execution looks like when executing setup scripts and verifying directory writes:

Common Termux Storage Errors and Solutions
Error 1: "Permission Denied" on External MicroSD Card
Cause: Android restricts write access to external physical SD cards for non-system apps.
Fix: Android only allows Termux to write to its specific private directory on external SD cards. Access your external card using the private path rather than root storage:
cd /storage/XXXX-XXXX/Android/data/com.termux/files/
Note: Replace XXXX-XXXX with your actual SD card UUID found via ls /storage.
Error 2: "termux-setup-storage: command not found"
Cause: Broken base packages or corrupted terminal environment installation.
Fix: Update and reinstall core termux packages using the following sequence:
pkg update && pkg upgrade -y
pkg install termux-tools -y
Summary Checklist
To keep your environment running smoothly without storage roadblocks:
- Always install Termux from F-Droid, not the Google Play Store.
- Run
termux-setup-storageimmediately upon a fresh installation. - Use
~/storage/shared/or~/storage/downloads/when interfacing with standard Android user files. - Ensure Android's "Allow management of all files" permission switch remains enabled under OS app settings.
What to Do Next
Now that you have successfully fixed your storage permission issues and bridged Termux with your Android device's file system, you can start running powerful Linux tools locally.
Ready to customize your workspace further? Read our complete step-by-step tutorial on How to Access and Manage External SD Cards in Termux to easily handle external drives, micro-SD storage, and backup strategies!
Join the conversation