Linux on Android
I wrote a document about installing Alpine Linux on an Android device some time ago. Here is how I am actually are doing it.
This post is not yet finished and will be updated continuously! When it is almost complete I will move the content to a new document…
I am using Samsung SM-T585 with 16GB storage with a custom ROM for Samsung Galaxy Tab A 10.1 2016 (SM-T585) installed. After OS installation I have rooted this device using Magisk even when it is not secure, but I only use this device for developement and there is no private data stored on the device. I will not explain the installation and/or rooting of custom ROM’s here! Installing a custom ROM and rooting the device is not required to use Linux on Android!
I will test the whole procedure on a stock Samsung Android ROM in a few days. Maybe I will root the stock ROM too, but I don’t know if that really works…
At first I need Termux installed on the tablet. I recommend to use F-Droid for installing apps. I don’t know if Termux is the same in the Google Play Store, so I just don’t use it from there.
Steps to reproduce:
This list may be incomplete. Please report errors!
- Install Termux
- Open Termux
- echo “nameserver 9.9.9.9” > ../usr/etc/resolv.conf
- echo “nameserver 149.112.112.112” >> ../usr/etc/resolv.conf
- Do default configuration of Termux by following the instructions
- Update Termux and install required packages
- pkg upgrade
- pkg add 7z
- pkg add net-tools
- pkg add openssh
- pkg add proot-distro
- pkg add termux-auth
- pkg add termux-tools
- pkg add vim
- pkg add wget
- pkg add zsh
- pkg add zsh-completions
- termux-setup-storage
- wget https://hanez.org/files/home.7z
- 7z x home.7z
- echo “export PATH=/data/data/com.termux/files/home/bin:\$PATH” > .penv
- chsh -s zsh
- su -
- hostname hacked-sm-t585 # This will be reset to “localhost” on a reboot!
- mkdir /data/root
- cd /data/root
- cp /data/data/com.termux/files/home/home.7z /data/root/
- 7z x home.7z
- rm -f home.7z
- echo “export PATH=/data/root/bin:\$PATH” > .penv
- echo “cd /data/root” » .penv
- exit
- rm -f home.7z
- exit # This exits Termux.
- Open Termux and have fun…!
- su.sh # This makes you root with a nice configured environment… ;)
Let’s install Linux now:
I will show the installation of Alpine Linux here, but there are more distributions available. You can see available distributions using the command “proot-distro list”. Actually you can select the following distributions for installation:
- Adélie Linux
- Alpine Linux
- Arch Linux
- Artix Linux
- Chimera Linux
- Debian (bookworm)
- deepin
- Fedora
- Manjaro
- OpenSUSE
- Pardus
- Rocky Linux
- Ubuntu (24.04)
- Void Linux
To be honest, we are not installing Linux here. Android provides the Linux Kernel. We are just installing a Linux distribution’s filesystem image and are “prooting” to it.
- Open Termux
- proot-distro install alpine
- proot-distro login alpine
- apk update
- apk upgrade –available
- apk add 7zip
- apk add vim
- apk add wget
- apk add zsh
- apk add zsh-completions
- apk add zsh-vcs
- chsh -s zsh
- wget https://hanez.org/files/home.7z
- 7z x home.cfg
- rm -f home.cfg
- echo “export PATH=/root/bin:\$PATH” > .penv
- exit
- proot-distro login alpine
SSH server:
- Start Termux
- passwd
- sshd
By default in Termux the SSH daemon is listening on port 8022 as you can not open ports below id 1000 in Termux as you are not root here. You can see the username in Termux at the lower left corner of the terminal or by running the “id” command and you can get the IP address by running “ifconfig”.
On the client:
# ssh -p 8022 u0_a162@10.0.0.23
Some Links:
- Android - A mobile operating system based on a modified version of the Linux kernel and other open-source software
- F-Droid - An installable catalogue of FOSS (Free and Open Source Software) applications for the Android platform
- PRoot - A user-space implementation of chroot, mount –bind, and binfmt_misc
- PRoot Distro - A Bash script wrapper for utility proot for easy management of chroot-based Linux distribution installations
- Quad9 - A free service that replaces your default ISP or enterprise Domain Name Server (DNS) configuration
- Termux - An Android terminal emulator and Linux environment app that works directly with no rooting or setup required
- Zsh - A shell designed for interactive use, although it is also a powerful scripting language
Permalink: https://hanez.org/2025/07/02/linux-on-android/