📱💻 Turn Your Old Android Phone into a Tiny Linux Server for Coding
So I had an old Android phone lying around collecting dust. I reset it, installed Python on it, and figured I'd document the process for others—especially for folks who don't have a Raspberry Pi or similar devices! (You can totally do this on your daily driver too, but like any app, it'll use some storage and battery.)
There are many ways to do this, but I'll walk you through two easy and well-known methods:
- Termux (simpler but more limited)
- UserLand (a bit more flexible)
1️⃣ Using Termux
Termux is easy to set up and doesn't need root access, but some features (like Docker) won't work unless your phone is rooted. For more flexibility, I'll show UserLand next.
- Install F-Droid .
- From F-Droid, install Termux (or from Google Play if you prefer, but it may have more limitations).
⚙️ Basic Linux Setup in Termux
Open Termux and run the following:
# Update Termux packagespkg update && pkg upgrade# Check battery statuspkg install termux-api && termux-battery-status# Install SSH for remote terminal accesspkg install openssh# Set a password for SSHpasswd# Start the SSH servicesshd# Find your phone's IP address (note the number after 'inet')ifconfig | grep 'inet ' | grep -v '127.0.0.1'# Keep Termux awaketermux-wake-lock💻 Remote Access via Termius (mobile or desktop)
To connect to the phone's SSH, ensure that both your device and the phone are on the same network.
- Install Termius Android or Termius Windows , we'll use Android version but they've similar configurations.
- Tap ➕ → New Host
:
- Alias : Any name (e.g., your phone model)
- IP Address
: The one from
ifconfig - Port
:
8022 - Username
:
username - Password
: The one you set with
passwd
Now you can SSH into your Android phone from your laptop or another phone!
🐍 Install Python & tmux
# Update Linux packagesapt update && apt upgrade -y# Install latest Pythonpkg install python# Install tmux for multitaskingpkg install tmux# Start a new tmux session (detach with Ctrl+B, then D)tmux -u new-session -s mytmux# Install speed test libpip install speedtest-cli# Run speed test via Pythonpython3 -c "import subprocess; subprocess.run(['speedtest-cli', '--bytes'])"You can even set a static IP for your phone via your router to avoid changing IPs every time.
If you face repo errors, update Termux repositories:
termux-change-repo⚠️ Termux doesn't support Docker natively, but you might be able to use Podman (haven't tested it myself).
More on Termux:
📖
Termux Wiki
2️⃣ Using UserLand
Everything mentioned for Termux kinda applies here too.
- Install UserLand from F-Droid or Google Play .
- Choose a Linux distro to install (supports Alpine, Arch, Debian, Kali, Ubuntu). I used Ubuntu for simplicity.
UserLand will ask for storage permissions and then prompt you to set a username and password (up to 8 characters). You'll need this password every time you enter the terminal.
⚙️ Ubuntu Setup in UserLand
# Update packagessudo apt update && sudo apt upgrade -y# Install basic toolssudo apt install -y lsb-release net-tools apt-utils tmux# Install and configure SSHsudo apt install -y openssh-server# Set your password againpasswdservice ssh startNote: You might see minor warnings using
sudowithout root, but it's generally safe to proceed.
🐍 Install Python & Rust
# Install Pythonsudo apt install -y python3 python3-pip python3-venvecho "✅ Installed Python version: $(python3 -V)"# Install Rustcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shsource ~/.cargo/envecho "✅ Installed Rust: $(rustc -V) & Cargo: $(cargo -V)"🐳 Install Docker
sudo apt updatesudo apt install -y docker.iosudo systemctl enable dockersudo systemctl start dockerdocker --version