~/androidlabs / apps / termux-secondary-user
// File 04 · Declassified
Termux Secondary User
patch set ยท 0.118.3-mu1Termux, working in secondary users and profiles. User 0 stays untouched.
Official Termux refuses to run in a secondary Android user with "can only be run as the primary user". This patch set makes it work on multi-user phones and GrapheneOS profiles, and changes nothing in user 0.
// Briefing
What it is
Termux hardcodes its data path to /data/data/com.termux, which is user 0's location. In a secondary user the app's data lives in /data/user/<N>/com.termux, so upstream Termux refuses to install its bootstrap there.
This project is a small, auditable patch set on the official Termux source. What you install is a complete Termux, built from that source plus the patches and signed with our key. The package name stays com.termux, so Termux's packages and pkg upgrade keep working.
Independent project. Not affiliated with or endorsed by the Termux project.





// Procedure
How it works
- 01Termux starts and checks which Android user it is in. In user 0 it starts normally, with no root and nothing changed.
- 02In a secondary user it asks Magisk for root inside its own process (
su -t <pid>). - 03Safety checks: it must be inside the app's private mount namespace, never init's, and no shared mounts.
- 04It bind-mounts
/data/user/<N>onto/data/datainside the Termux process only. - 05It verifies inode and owner, then continues the normal Termux start. If any check fails, it unmounts and reports the error.
The only change it makes is one line:
/system/bin/mount -o bind "/data/user/$USER_ID" "/data/data"The mount exists only in the Termux process and disappears when that process dies. Nothing is mounted globally.
// Boundaries
What it does not do
- It does not touch SELinux or Android permissions.
- It does not mount anything for other apps or for the system, and nothing survives the process.
- It does not change Termux's package name, prefix, bootstrap or packages.
- It adds no network code and no new Android permissions.
- It never uses root in user 0.
- It does not copy or move your data.
// Requirements
Magisk settings that matter
| Setting | Use | Otherwise |
|---|---|---|
| Multiuser Mode | User-Independent or Device Owner Managed | Device Owner Only, the default, denies root to every secondary user. Termux shows a "setup failed safely" screen. |
| Mount Namespace Mode | Inherit Namespace | Global behaves the same. Isolated is refused with a message. |
Tested on a Google Pixel 8a with Android 17 and Magisk 31.1, in users 10 and 11 at once. Not yet tested: KernelSU, APatch, work profiles.
// Known limits
Read before you install
- Termux plugins are not released. In a secondary user only Termux:Styling worked in tests.
- The mapping disappears when the Termux process dies and is set up again on the next start.
- The first launch can wait for the Magisk prompt, up to 90 seconds.
- No side-by-side install with official Termux, and no data migration.
- Inherited from upstream: targetSdk 28.
// Verification
Check what you install
sha256sum -c SHA256SUMS.txt
gh attestation verify <apk> --owner AndroidLabs-org
apksigner verify --print-certs <apk>The signing certificate SHA-256 must be:
dac9bda20bb9cb1a9be04fc9741d54e1ab14f09df049f911542b92e1f87c6393Every release ships checksums, GitHub build attestations and the full source tarball. A new release is published only if the patches apply cleanly and the tests pass.