Termux filesystem layout (project documentation)
The Termux project's own reference for where its files live and why the layout departs from a Linux
distribution's. T1 — first-party documentation from termux/termux-packages, the repository that
builds the packages it describes.
Sourcing note. The page the curator sent was wiki.termux.com/wiki/Differences_from_Linux, which
is behind an Anubis proof-of-work anti-bot gate (version 1.25.0) that blocks WebFetch, Firecrawl,
a plain curl, MediaWiki's action=raw and api.php, a reader proxy and the Google-translate
mirror alike; the Wayback Machine was returning 503 across three attempts at the time of ingest. The
gate is a deliberate operator choice, so this ingest rests on the project's accessible sibling
page on GitHub, which covers the same ground from the same project. Nothing below is taken from the
blocked page. Worth re-running against the original if it becomes reachable.
The prefix is the whole story
$TERMUX__PREFIX ($PREFIX) defaults to /data/data/com.termux/files/usr and does the job of
/usr. Underneath it: bin (which collapses /bin, /sbin, /usr/bin and /usr/sbin into one
directory), etc, include, lib, libexec, opt for sideloaded packages, share, tmp, and
var. So /tmp and /var/tmp are one directory inside the app's private storage, freely writable by
the user and erased on restart, and subject to deletion by Android when free storage falls to 150%
of the low-storage threshold.
Why it cannot follow the FHS
The reason given is not preference. Android does not grant write access to system directories under
the filesystem root without root, so there is nowhere to put /usr even if the project wanted to. The
second reason is stronger and is the one that rules out a fix: Android's binaries and Termux's are
each linked against their own compatible shared libraries, so mixing the two sets in shared system
directories would break both environments rather than unify them.
The consequence for every package: hardcoded FHS paths in upstream source are patched at build time and rewritten to the prefix. Termux is not Debian with a different mount point; it is a distribution whose entire package set has been rewritten to a new root, which is why a binary pulled from a Debian mirror does not run and why every tool has to be built for the platform.
The shebang limit, which is a real constraint and not a curiosity
The kernel caps a script's #! line at 128 characters on Linux < 5.1 and 256 on ≥ 5.1. A prefix
that starts with /data/data/com.termux/files/usr eats a large fixed share of that budget before the
interpreter path begins. The project's answer is termux-exec in LD_PRELOAD, which raises the
effective limit to 340 characters.
This is the mechanism behind a class of failure a phone user meets constantly and rarely diagnoses: a
cloned repository whose scripts carry #!/usr/bin/env python or a long absolute path simply fails to
execute, with an error that names neither the prefix nor the limit.
Root is documented as a way to break the install
The page recommends against it, and the reason is specific rather than general security advice: files
created or chowned by root under $TERMUX__ROOTFS stop being usable by the app's own processes,
which run as the app's UID. The package managers are patched to refuse to run as root for that
reason. Three mechanisms enforce the isolation — UID-based discretionary access control, SELinux
Multi-Category Security, and isolated mount namespaces on newer Android — and disabling SELinux is
explicitly not recommended.
What this changes on termux
That page has carried a paragraph of platform constraints since 2026-08-03 marked as inference — "the platform's, not claims from termux-commands-site, which never mentions them." Two of them now have first-party backing (packages must be built for the platform; root is not merely absent but contraindicated), and the shebang limit is a constraint the page did not know about. The claim about Android reaping long-running background processes is not addressed here and stays unsourced.