Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Linux Terminal on Android: 8 Ways to Use It

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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.

  1. 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.
  2. Open Termux. You'll see a command prompt. Run pkg update and then pkg upgrade to update the package list and installed packages. This is essential before installing anything.
  3. Install common packages: pkg install openssh python vim git – this gives you SSH client, Python, Vim editor, and Git.
  4. 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.
  5. Run Python scripts: create a file with nano script.py, write your code, then run it with python script.py.
  6. 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.

  1. Install UserLAnd from the Google Play Store.
  2. Open the app, choose a distribution (Ubuntu is a good start), and set a username and password.
  3. Wait for the download and setup – this can take a few minutes.
  4. 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).
  5. 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.

  1. Install Termius from the Google Play Store.
  2. Open the app and tap the plus icon to add a new host.
  3. Enter your server's IP address, username, and password (or paste an SSH key).
  4. 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.

  1. Install "Terminal Emulator" from the Play Store (look for one with good ratings, e.g., "Terminal Emulator for Android").
  2. 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.
  3. Use it for quick file operations or to run su if 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.

  1. Open your phone's browser and go to shell.cloud.google.com.
  2. Sign in with a Google account – you get a free temporary VM with a Linux shell.
  3. 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.

  1. In Termux, install PHP: pkg install php.
  2. Create a folder for your site: mkdir ~/www and place your PHP files there.
  3. Start the server: php -S 0.0.0.0:8080 -t ~/www.
  4. 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.

  1. Install cron: pkg install cronie.
  2. Start the cron daemon: crond.
  3. Edit your crontab: crontab -e and add lines like 0 8 * * * echo "Good morning" >> ~/morning.txt.
  4. 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.

  1. In Termux, navigate to your storage: termux-setup-storage (grants access to shared storage).
  2. Now you can use commands like cp, mv, rm, find on 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 update before installing – you'll get errors about missing packages.
  • Using sudo in Termux – Termux doesn't use sudo by default; you are the root user in its environment. Use pkg instead of apt for package management.
  • Not granting storage access – you'll see "Permission denied" when trying to access /sdcard. Run termux-setup-storage first.
  • 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-keygen and copy with ssh-copy-id.
  • Use tmux in 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:

  1. Restart the app – close Termux and reopen it.
  2. Check your internet connection – many commands need to download packages.
  3. If you get "Unable to locate package", run pkg update first.
  4. If SSH fails, verify the server address and port, and ensure the server allows password auth.
  5. If UserLAnd fails to start, clear its cache in Android settings (Settings > Apps > UserLAnd > Storage > Clear Cache). This does not delete your data.
  6. 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.