Running a Linux distro inside Termux does not require root, but you do need a device that can install apps from unknown sources and has at least 2 GB of free storage for a comfortable Ubuntu installation. A stable Wi‑Fi connection is recommended because the first setup downloads several hundred megabytes.
termux-setup-storage later.After the initial setup you will see a clean command line prompt like ~ $. This is your Linux‑compatible shell.
pkg update
pkg upgrade -y
pkg install proot-distro wget curl git -y
Running pkg upgrade ensures the proot-distro script works with the current Termux runtime.
proot-distropkg install proot-distro -y
proot-distro --help
You should see a list of commands such as install, login, and list.
proot-distro uses proot to emulate a chroot environment, meaning the Linux distro runs in user space without needing root privileges.
proot-distro list
Typical entries include ubuntu, debian, alpine, and archlinux.
proot-distro install ubuntu-22.04
~/.local/share/proot-distro/installed/ubuntu-22.04. This may take 5‑10 minutes depending on your connection.When the command finishes you will see a short success message. The distro is now ready but not yet running.
proot-distro login ubuntu-22.04
root@localhost:~#.adduser androiduser
Follow the prompts – you can leave the GECOS fields blank.
usermod -aG sudo androiduser
su - androiduser
From now on you can treat the session exactly like a regular Ubuntu terminal.
Termux maps the shared /sdcard directory into the Linux rootfs, allowing you to read and write files that are visible to other Android apps.
cd /sdcard
ls -l
termux-setup-storage from the original Termux session (outside the distro) and try again.Note that the Linux user sees the Android file system with Linux permissions, but the underlying Android SELinux policy still governs actual access. Avoid changing ownership or permissions of files in /sdcard – it can break other apps.
Ubuntu’s package manager apt works out of the box. First update the package index, then install what you need.
sudo apt update
sudo apt install build-essential git vim python3-pip -y
python3 --version
All installed binaries reside inside the distro’s rootfs, isolated from the Android system. You can safely experiment without affecting the host.
If you need a GUI (e.g., for graphical editors, browsers, or teaching), you can run a lightweight desktop environment and view it through a VNC client on Android.
sudo apt install xfce4 xfce4-terminal dbus-x11 -y
sudo apt install tigervnc-standalone-server -y
vncpasswd
:1 with a resolution of 1280×720:
vncserver :1 -geometry 1280x720 -depth 24
Ctrl + D or type exit twice) and install a VNC viewer from the Play Store (e.g., VNC Viewer by RealVNC).127.0.0.1:5901. You should see the XFCE desktop.vncserver -kill :1
Running a desktop consumes more RAM and CPU, so keep an eye on the device’s temperature. For short sessions it works well, but for prolonged use consider a dedicated tablet or a low‑power SBC.
Typing the full proot-distro login … command each time can be tedious. You can add simple shell aliases or wrapper scripts.
.bashrc (or .zshrc if you use Zsh):
nano ~/.bashrc
# Shortcut to launch Ubuntu
alias ubuntu='proot-distro login ubuntu-22.04'
# Shortcut to stop all proot processes
alias ubuntu-stop='pkill -f proot-distro'
Ctrl+X → Y → Enter).source ~/.bashrc
ubuntu command and stop it with ubuntu-stop.Because the distro lives in a regular file hierarchy, you update it exactly as you would on a native installation.
proot-distro login ubuntu-22.04
sudo apt update && sudo apt full-upgrade -y
sudo apt autoremove -y && sudo apt clean
The rootfs stays the same; only the package contents change, so you do not need to reinstall the whole image.
This usually means the proot-distro package was not installed correctly. Re‑run:
pkg install proot-distro -y
and ensure ~/.local/bin is in your $PATH. You can add it to .bashrc if necessary:
export PATH=$HOME/.local/bin:$PATH
Check available storage with df -h in Termux. If the internal partition is full, clear unused apps or move the distro to external storage:
/sdcard/termux-distros.proot-distro to use it:
mkdir -p $HOME/.local/share/proot-distro/installed && ln -s /sdcard/termux-distros $HOME/.local/share/proot-distro/installed
Some manufacturers (e.g., Samsung) apply stricter SELinux policies that block certain proot operations. The workaround is to enable the “Allow access to external storage” option in Termux settings, then restart Termux. If the problem persists, you may need to install the termux-exec package:
pkg install termux-exec
By default the distro shares the host’s network stack, but a mis‑configured proxy can break it. Inside Ubuntu run:
ping -c 3 8.8.8.8
If ping works but DNS fails, edit /etc/resolv.conf to include a public DNS server:
echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf
Make sure the X‑session is started with the correct display. After installing XFCE, create a startup script:
echo "startxfce4" > ~/.vnc/xstartup
chmod +x ~/.vnc/xstartup
Then restart the VNC server.
~/.local/share. Back up this folder (e.g., via tar -czf ubuntu-backup.tar.gz ~/.local/share/proot-distro/installed/ubuntu-22.04) if you plan to wipe the device.dpkg --print-architecture inside Ubuntu to verify you are pulling the correct binaries.With these precautions in place, you now have a fully functional Linux environment on your Android phone – ready for coding, server testing, or just satisfying curiosity.









