Set up a Linux Distro on Android Device with Termux: Best Linux Terminal for Android

Posted on

Set up a Linux Distro on Android Device with Termux: Best Linux Terminal for Android

Set up a Linux Distro on Android Device with Termux: Best Linux Terminal for Android

This guide aims to teach you how to Set up a Linux Distro on Android Device with Termux. If you’re looking to use a Linux terminal on your Android device, Termux is an excellent, free, and open-source tool that provides a terminal environment directly on your Android. It’s particularly useful when you don’t have access to a PC, allowing you to write and execute code directly from your phone or tablet.

Let’s dive into the process of how to Set up a Linux Distro on Android Device with Termux.

Step 1 – Termux Setup on Android

While you can download Termux directly from the Play Store, the version available there is often outdated and no longer receives updates. To ensure you have the latest version, we’ll use an app called Andronix to help with the setup.

First, download Andronix – Linux on Android from the Play Store.

[Image of Andronix – Linux on Android in Play Store]

Once the installation is complete, open the Andronix app. You’ll be presented with the main screen. Click on Linux Distribution.

[Image of Andronix main screen with Linux Distribution option highlighted]

Next, you’ll see the Distro selection screen. Choose your desired Linux distribution. In this example, we’ll select Ubuntu.

[Image of Andronix Distro selection screen with Ubuntu selected]

Now, choose your preferred Ubuntu version. We’ll use Ubuntu 22.04 as our Linux distro on our Android device.

[Image of Andronix Ubuntu version selection screen with Ubuntu 22.04 selected]

You’ll then be presented with the GUI selection screen. Since we want to use a command-line interface (CLI) for our tasks, click on CLI Only.

[Image of Andronix GUI selection screen with CLI Only selected]

At this point, you’ll see a page that directs you to download Termux on your Android device. Click on Open Termux.

[Image of Andronix screen with the "Open Termux" option]

Important Note: The Andronix app automatically copies a command to your clipboard when you reach this page. Keep this command safe! If you lose it, simply go back and click the Recopy button.

Next, click on Download Termux on your Android device.

[Image of Andronix screen with the "Download Termux" option]

Wait for the Termux download to complete. Once finished, click on the downloaded file and select Install.

[Image of Android installation screen for Termux]

Step 2 – How To Run Termux Linux Terminal on Android?

After Termux is installed, open the app. You’ll see a welcome screen:

[Image of Termux welcome screen]

Important Note: Immediately paste the command you copied from Andronix into the Termux terminal. Click anywhere on the screen to bring up the paste option, then paste and press Enter.

This command will update and upgrade all necessary packages and dependencies, setting up your Ubuntu Linux environment on your Android device.

After the process is complete, type exit in your Termux terminal:

$ exit

Next, reopen the Termux terminal and run the following command to start your Ubuntu environment:

./start-ubuntu22.sh

Now you have a functioning Ubuntu shell on your Android device, and you can run your Linux Commands.

Note: If you encounter issues installing packages due to DNS resolution problems, run the following command in your Termux Linux terminal:

echo "nameserver 8.8.4.4" > $PREFIX/etc/resolv.conf

That’s it! You’ve successfully completed the setup to Set up a Linux Distro on Android Device with Termux.

Conclusion

You’ve now learned how to Set up a Linux Distro on Android Device with Termux. This fantastic tool allows you to have a Linux terminal shell on your Android device and execute code from anywhere. In this guide, we set up an Ubuntu distribution using the Andronix app. To change your Linux distribution, return to the Andronix app and repeat the steps, selecting a different distribution.

Enjoy using your Linux shell on your Android Device.

Alternative Solutions to Setting Up a Linux Environment on Android

While Andronix offers a convenient method, there are alternative ways to achieve a similar outcome, offering different levels of customization and control.

1. Using UserLAnd

UserLAnd is an open-source application that allows you to run several Linux distributions on Android without requiring root access. Unlike Andronix which relies on a pre-configured script, UserLAnd provides more flexibility in choosing the specific packages and desktop environment (if desired) to install.

Explanation:

UserLAnd leverages the Android’s proot (process root) mechanism, creating a contained Linux environment within your Android file system. This approach avoids system-level modifications and ensures compatibility with most devices. UserLAnd offers a selection of distributions like Debian, Ubuntu, Alpine, and Arch Linux. It allows you to select a pre-configured environment (e.g., SSH-only, XFCE desktop) or customize the installation from scratch.

Steps to use UserLAnd:

  1. Install UserLAnd: Download and install the UserLAnd app from the Google Play Store.
  2. Choose a Distribution: Open UserLAnd and select your desired Linux distribution from the list.
  3. Select a Session Type: Choose a session type (e.g., SSH, VNC, XSDL). SSH provides a command-line interface, while VNC and XSDL offer graphical desktop environments.
  4. Configure Settings: Configure the username, password, and other settings as prompted.
  5. Download and Install: UserLAnd will download and install the necessary files to create the Linux environment.
  6. Connect: Once the installation is complete, connect to the Linux environment using the selected session type.

Code Example (Connecting via SSH after installation):

After installing Debian via UserLAnd with SSH, you can connect to it using Termux itself (after installing the openssh package in Termux):

ssh <username>@localhost -p 8022

Replace <username> with the username you configured during the UserLAnd setup. Port 8022 is the default SSH port used by UserLAnd; verify it within the UserLAnd settings.

UserLAnd provides more control over the installed environment and its dependencies, but requires more manual configuration compared to Andronix.

2. Using a Full Virtual Machine with Limbo PC Emulator

For a more complete Linux experience, consider using a full virtual machine emulator like Limbo PC Emulator. This approach allows you to run a standard Linux ISO image within a virtualized environment on your Android device, offering the closest experience to running Linux on a desktop computer.

Explanation:

Limbo PC Emulator emulates the hardware components of a PC, allowing you to install and run operating systems designed for x86 architecture. This means you can install a desktop Linux distribution like Fedora, Debian or Ubuntu directly from its ISO image. However, this method is considerably more resource-intensive and requires a relatively powerful Android device to function smoothly.

Steps to use Limbo PC Emulator:

  1. Install Limbo PC Emulator: Download and install the Limbo PC Emulator APK. (Note: This is often available from sources outside the Play Store; exercise caution when downloading APKs from untrusted sources.)

  2. Download a Linux ISO Image: Download the ISO image of your preferred Linux distribution (e.g., Ubuntu Desktop).

  3. Configure Limbo: Open Limbo and create a new virtual machine. Configure the following settings:

    • Architecture: x86
    • CPU Model: Core2Duo or similar
    • RAM: Allocate as much RAM as your device can spare (512MB or more is recommended).
    • CDROM: Select the downloaded Linux ISO image.
    • Hard Disk: Create a new hard disk image (e.g., disk.img) and allocate sufficient space (e.g., 10GB).
    • Boot from CDROM
  4. Start the VM: Start the virtual machine. Limbo will boot from the ISO image.

  5. Install Linux: Follow the on-screen instructions to install Linux onto the virtual hard disk.

  6. Reconfigure Limbo (after installation): After installation, shut down the VM. Reconfigure Limbo to boot from the hard disk image instead of the CDROM.

  7. Start the VM (again): Start the virtual machine again. This time, it will boot from the installed Linux system.

Code Example (No direct code example, but Limbo configuration snippets):

Limbo configuration is done through its GUI, but here’s a conceptual representation:

VM Name: UbuntuVM
Architecture: x86
CPU Model: Core2Duo
RAM: 1024MB
CDROM: /sdcard/download/ubuntu.iso
Hard Disk: /sdcard/limbo/disk.img (10GB)
Boot: Hard Disk

This method provides the most complete Linux experience, but it’s also the most demanding in terms of system resources and setup complexity. Performance might be limited depending on your Android device’s hardware. While Set up a Linux Distro on Android Device with Termux is easy and fast, Limbo is comprehensive but demands time and resources.

These alternative methods provide varying levels of control and functionality, allowing you to choose the approach that best suits your needs and device capabilities when you want to Set up a Linux Distro on Android Device with Termux. While the original article details a simple method to Set up a Linux Distro on Android Device with Termux, these options offer more control.

Leave a Reply

Your email address will not be published. Required fields are marked *