Installing the su binary in Termux grants root privileges for system-level operations, but it requires a rooted Android device. You must first install the
tsu package via
pkg install tsu, then configure permissions and verify access using
su. This process allows advanced users to execute commands with elevated security clearance on compatible hardware.
Prerequisites and Device Requirements
Before attempting to install or utilize the
su binary within Termux, it is crucial to understand that this operation is strictly dependent on the underlying state of your Android operating system. The
su command is not a standalone application that can be installed independently; rather, it is a utility that interfaces with the kernel's permission management system. Therefore, your Android device must already possess root access. Without a rooted environment, any attempt to invoke
su will fail immediately because there is no superuser daemon running to authorize the request.
Most modern Android devices do not come with root access enabled by default due to security restrictions imposed by manufacturers and Google. To proceed, you typically need to unlock the bootloader and flash a custom recovery image, such as TWRP (Team Win Recovery Project), followed by installing a rooting manager like Magisk or KernelSU. These tools modify the system partition to allow specific applications to request elevated privileges. If your device is not rooted, you should skip this guide, as proceeding without root will result in persistent errors and potential instability in your development environment.
Additionally, ensure that your Termux application is updated to the latest version available through F-Droid or GitHub. Older versions may have compatibility issues with newer Android security patches or may lack the necessary scripts to handle privilege escalation correctly. It is also advisable to disable any battery optimization settings for Termux to prevent the system from killing background processes that might be required during the configuration phase.
Installing the tsu Package
Once you have confirmed that your device is rooted and Termux is up to date, the next step is to install the terminal user switcher package. In standard Linux distributions, the
su binary is often part of the core system utilities. However, Termux operates in a sandboxed environment and does not include
su by default to maintain security and stability. Instead, the Termux community provides a dedicated package called
tsu, which acts as a wrapper around the system's
su binary.
Open your Termux terminal and execute the following command to update your package lists:
pkg update
After the update completes successfully, install the
tsu package by running:
pkg install tsu
This command downloads the necessary binaries and scripts from the Termux repository. The
tsu package is designed to intelligently detect the presence of various root managers, including Magisk, SuperSU, and others, ensuring compatibility across different rooting solutions. Once the installation finishes, you should see a confirmation message indicating that the package was installed successfully. This step is essential because it bridges the gap between Termux's user space and the privileged kernel space provided by your rooted device.
For those interested in understanding how other applications handle updates or installations in different environments, you might find it useful to read about
Why don't desktop apps offer to install updates after the app is closed? as it highlights differences in update mechanisms across platforms.
Configuring Root Permissions
After installing
tsu, you must grant Termux the permission to access the root shell. When you first attempt to use
tsu, your device will display a prompt from your root manager (e.g., Magisk) asking whether to grant Termux superuser access. You must select "Grant" or "Allow" to proceed. If you deny this request, subsequent attempts will fail, and you will not gain root privileges.
It is important to note that some root managers may require you to explicitly add Termux to their whitelist or trusted applications list. In Magisk, for example, you can navigate to the Magisk app settings and ensure that Termux is checked under the "DenyList" if you are using Zygisk, or simply ensure it is allowed in the main permissions menu. Failure to configure these settings correctly is a common reason why users report that
su is not working despite having a rooted device.
You should also verify that the
tsu script has the correct execution permissions. Although the package manager usually handles this automatically, you can manually check by running:
ls -l $(which tsu)
The output should show executable permissions (
x) for the owner. If permissions are missing, you can fix them with:
chmod +x $(which tsu)
This ensures that the system can properly execute the script when you invoke it. Proper configuration at this stage prevents many common errors related to permission denied messages or silent failures.
Verifying and Using Root Access
To confirm that the installation was successful and that you have active root access, run the
tsu command in your Termux terminal:
tsu
If configured correctly, the prompt will change, often indicating that you are now the root user (e.g., the prompt may change from
$ to
#). You can verify your current user identity by running:
whoami
The expected output should be
root. If the output is still your regular user name, it means the root request was denied or the configuration is incorrect. You should return to your root manager app to review the permissions granted to Termux.
Once verified, you can execute any command with root privileges by prefixing it with
tsu or by staying in the root shell. For example:
tsu ls /system
This command lists the contents of the system directory, which is normally inaccessible to non-root users. Be cautious when executing commands as root, as mistakes can lead to system instability or data loss. Always double-check your commands before pressing enter. Understanding how these permissions interact with other software can help troubleshoot broader issues, such as those discussed in
Desktop Entry Equivalents on Windows and MacOS, where cross-platform compatibility affects user experience.
Troubleshooting Common Issues
If you encounter errors while trying to use
tsu, several factors could be responsible. First, ensure that your device is truly rooted. Some "root" methods are incomplete or unstable and may not support the
su interface required by Termux. Second, check if your root manager is blocking Termux. Some security-focused root managers may restrict access to certain apps by default. Third, verify that Termux is not being killed by the Android OS. Background restrictions can interrupt the connection to the root daemon.
Another common issue is related to SELinux (Security-Enhanced Linux). On some devices, SELinux may be in enforcing mode, which blocks unauthorized access to system resources. While
tsu handles most SELinux contexts, some advanced operations may require SELinux to be permissive, which is generally not recommended for daily use due to security risks. If you suspect SELinux is the cause, you can check its status with:
getenforce
If it returns
Enforcing, and you are facing specific permission errors, you may need to consult your device-specific XDA Developers forum for guidance on safely adjusting these settings. Remember that modifying SELinux policies can compromise your device's security posture.
Frequently Asked Questions
Can I install su binary on an unrooted Android device?
No, you cannot install or use the
su binary on an unrooted device. The
su command requires kernel-level privileges that are only available after rooting the device. Attempting to run it without root access will result in a permission denied error.
Why does tsu ask for permission every time I use it?
This behavior is normal and is controlled by your root manager (such as Magisk). Each time
tsu requests root access, the root manager prompts you for authorization to ensure security. You can often configure your root manager to remember the decision and auto-grant permission to Termux in the future.
Is it safe to use tsu for everyday tasks?
Using
tsu is generally safe if you only execute commands you trust. However, running arbitrary scripts or commands as root can damage your system or compromise security. Always verify the source of any command before executing it with elevated privileges.
What should I do if tsu fails to start?
First, ensure your device is properly rooted and that Termux has been granted root access in your root manager. Second, try reinstalling the
tsu package using
pkg install tsu --reinstall. If problems persist, check the Magisk or SuperSU logs for detailed error messages regarding why the request was denied.
Does Termux work without root access?
Yes, Termux functions perfectly well without root access for most development and scripting tasks. You can install packages, run Python scripts, and use compilers without needing
su privileges. Root access is only necessary for operations that require modifying system files or accessing restricted areas of the Android OS.