Linux Terminal on Android: 8 Ways to Use It
In this article
You can run a real Linux terminal on your Android phone without rooting it, and it's surprisingly useful for everything from quick SSH sessions to running Python scripts. This guide walks you through the main ways to get a terminal, what you can do with each, and my personal favorite method. You'll need an Android phone (Android 8 or newer is best), a Wi-Fi or mobile data connection, and about 15 minutes.
What You'll Need
- An Android phone or tablet
- Internet connection for downloading apps and packages
- Optional: a Bluetooth or USB keyboard if you plan to type a lot
- Optional: a server or computer you want to connect to via SSH
Step-by-Step
Method 1: Use Termux (My Favorite)
Termux is a powerful terminal emulator that gives you a Linux environment without rooting. It's the closest thing to a full Linux distro on Android, and it's what I use daily.
- Install Termux from the F-Droid app store (the Google Play version is outdated; use F-Droid for the latest). Download F-Droid from f-droid.org, then search for Termux and install it.
- Open Termux. You'll see a command prompt. Run
pkg updateand thenpkg upgradeto update the package list and installed packages. This is essential before installing anything. - Install common packages:
pkg install openssh python vim git– this gives you SSH client, Python, Vim editor, and Git. - Use SSH to connect to a server:
ssh user@server.com. You'll be prompted for a password. For better security, set up SSH keys later. - Run Python scripts: create a file with
nano script.py, write your code, then run it withpython script.py. - Use Git to clone repositories:
git clone https://github.com/username/repo.git.
Method 2: Use Termux with a Linux Distribution (UserLAnd)
If you want a full desktop Linux environment, UserLAnd runs Ubuntu, Debian, and Kali in a chroot-like environment.
- Install UserLAnd from the Google Play Store.
- Open the app, choose a distribution (Ubuntu is a good start), and set a username and password.
- Wait for the download and setup – this can take a few minutes.
- Once done, you'll get a terminal session inside that distribution. You can install packages with
apt(e.g.,sudo apt update && sudo apt install vim). - For a graphical interface, install a VNC client and use the VNC option in UserLAnd (the app guides you through this).
Method 3: Use a Simple SSH Client (Termius)
If you only need to connect to remote servers, a dedicated SSH client is lighter than a full terminal.
- Install Termius from the Google Play Store.
- Open the app and tap the plus icon to add a new host.
- Enter your server's IP address, username, and password (or paste an SSH key).
- Tap connect – you'll get a terminal session to that server.
Method 4: Use a Local Shell (Terminal Emulator)
For a basic local shell without package management, a simple terminal emulator works.
- Install "Terminal Emulator" from the Play Store (look for one with good ratings, e.g., "Terminal Emulator for Android").
- Open it – you'll get a shell that runs as your Android user. You can run basic commands like
ls,cd,pwd, but you cannot install Linux packages. - Use it for quick file operations or to run
suif your phone is rooted (but rooting is out of scope here).
Method 5: Use a Web-Based Terminal (Google Cloud Shell)
If you don't want to install anything, you can use a browser-based Linux terminal.
- Open your phone's browser and go to shell.cloud.google.com.
- Sign in with a Google account – you get a free temporary VM with a Linux shell.
- Use it for testing commands or running scripts. It's not persistent, but fine for quick tasks.
Method 6: Use a Local Web Server (Termux + PHP)
Turn your phone into a mini web server for testing.
- In Termux, install PHP:
pkg install php. - Create a folder for your site:
mkdir ~/wwwand place your PHP files there. - Start the server:
php -S 0.0.0.0:8080 -t ~/www. - Access it from your phone's browser at localhost:8080, or from other devices on the same network using your phone's IP address.
Method 7: Use Termux for Automation (Cron)
Schedule tasks on your phone using Termux's cron support.
- Install cron:
pkg install cronie. - Start the cron daemon:
crond. - Edit your crontab:
crontab -eand add lines like0 8 * * * echo "Good morning" >> ~/morning.txt. - Make sure Termux is allowed to run in the background (disable battery optimization for Termux in Android settings).
Method 8: Use Termux for File Management
Use the terminal to manage files on your phone more efficiently.
- In Termux, navigate to your storage:
termux-setup-storage(grants access to shared storage). - Now you can use commands like
cp,mv,rm,findon your files. For example,find /sdcard/Download -name "*.pdf"to list all PDFs.
Common Mistakes
- Installing Termux from the Play Store – it's outdated and often broken. Always use F-Droid.
- Forgetting to run
pkg updatebefore installing – you'll get errors about missing packages. - Using
sudoin Termux – Termux doesn't use sudo by default; you are the root user in its environment. Usepkginstead ofaptfor package management. - Not granting storage access – you'll see "Permission denied" when trying to access /sdcard. Run
termux-setup-storagefirst. - Expecting a full desktop environment in Termux – Termux is a terminal, not a full GUI. For GUI, use UserLAnd.
Tips
- Use a Bluetooth keyboard for serious typing – the on-screen keyboard lacks function keys and is slow.
- Enable extra keys in Termux: long-press the volume down key to bring up a row with ESC, TAB, CTRL, etc.
- Set up SSH keys for passwordless login – generate with
ssh-keygenand copy withssh-copy-id. - Use
tmuxin Termux to keep sessions alive even if you switch apps. - Keep Termux updated weekly to avoid security vulnerabilities.
Troubleshooting
If it does not go to plan:
- Restart the app – close Termux and reopen it.
- Check your internet connection – many commands need to download packages.
- If you get "Unable to locate package", run
pkg updatefirst. - If SSH fails, verify the server address and port, and ensure the server allows password auth.
- If UserLAnd fails to start, clear its cache in Android settings (Settings > Apps > UserLAnd > Storage > Clear Cache). This does not delete your data.
- If Termux crashes on start, try reinstalling from F-Droid (this will lose your packages, but you can reinstall them).
Frequently Asked Questions
Is Termux safe to use?
Yes, Termux is open-source and available on F-Droid. It only gives you access to your own device's files and network, just like any terminal on a computer.
Do I need root to use a Linux terminal on Android?
No. All methods in this guide work without root. Termux runs as a regular app with its own environment.
Can I run Linux GUI apps on my phone?
Yes, but not directly in Termux. Use UserLAnd with a VNC viewer to get a desktop environment like Ubuntu's XFCE.
Why can't I access /sdcard in Termux?
You need to run termux-setup-storage once to grant storage permissions. After that, you'll find your files under /sdcard.
Can I use the terminal to control my smart home devices?
Yes, if your devices have a command-line interface or an API. For example, you can use curl to send commands to a Home Assistant server or use SSH to a Raspberry Pi running automation scripts.
What is the easiest way to start?
Start with Termux and run pkg install openssh to practice SSH. It's the most flexible and well-documented option.