DEV Community

Cover image for Setting up Termux and a Linux Distro on Android
sahra ๐Ÿ’ซ
sahra ๐Ÿ’ซ

Posted on • Edited on • Originally published at dev.to

Setting up Termux and a Linux Distro on Android

WHAT IS TERMUX?

Termux is a free and open source terminal emulator for Android which allows for running a Linux environment on an Android device.
in simple terms: Termux is an application(app) that can be installed on any Android device. This app is used to provide a terminal environment right on your smartphone. Thought you could only use a linux terminal on a PC or desktop? well turns out you could actually have one right on your smartphone that runs exactly the same as the one on your PC.

With Termux, you can code anywhere, with just your smartphone, if you don't have have access to a PC at any point, termux is great to help with any of your programming related needs.

WHAT IS A LINUX DISTRO?

A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that includes the Linux kernel and often, a package management system. Linux distros consist of what are called software packages. These packages contain specific files, applications or services. A package could be a collection of fonts, web browsers or development environments. A single Linux distribution could contain thousands of software packages.

Running a linux distro in your termux is very important to give you the complete feel of using a linux terminal in your PC.

In this article, i would be walking you through not only setting up your termux, but also running a version of any of the varieties of linux distros out there.

HOW TO SETUP TERMUX

There are only a very few steps to setting up termux on your Android device.

I would have taken you through downloading termux directly from playstore, but unfortunately the version of termux available there has been depreciated and no longer receives updates. So we would be going through a more convenient route.
Key: if you had previously installed termux directly from playstore, delete it, then follow the below steps.

  1. Go to playstore and download an app called Andronix.

  2. Once the app is done installing, open it and this is the first page you would come across ๐Ÿ‘‡

First page of the Andronix app
These icon that you see are the different linux distros out there, you are to select one to set up in your termux. If you are a complete beginner and have no idea about how linux distros work or which one you need, just use the Ubuntu distro, this is one of the most widely used linux distros out there, and it's beginner friendly as well. Well which one is Ubuntu?

It is the first orange coloured icon you see, click it to get started.

3.Once you click that icon, it should take you to this page ๐Ÿ‘‡

Ubuntu distro page
Click on proceed.

  1. After you have clicked the proceed button, it should take you to this page ๐Ÿ‘‡
    Ubuntu version download page
    In this page, you are asked to pick what version of Ubuntu you would like to download. Again if you don't know, i would advice you to go with the 20.04(Focal fossa) version, so click on that one.

  2. If you clicked on the 20.04(Focal fossa), you should arrive at this page here๐Ÿ‘‡
    installation page of Ubuntu
    Click on install

6.After you clicked on the install button, it should take you to this page here๐Ÿ‘‡

Ubuntu installation page 2
Click on CLI only

  1. After that, it should take you here ๐Ÿ‘‡

Ubuntu installation 3
Click on open Termux this should direct you to the proper place to download termux (fdroid).
Important: There is a command that the Andronix app automatically copies into your clipboard when u on this page. Keep the command safe as i would show you where you would be needing it later on. (if you lose it, just go back and click the Recopy button).

  1. After your termux has been installed, open it, and it should look something like this ๐Ÿ‘‡

Termux terminal
You are in termux now, but termux is still plain.

Remember the command that was previously copied into your clipboard that i said to keep safe? Well here is where you use it.

So what you do now is to immediately paste the command into the terminal(click anywhere on your screen in the terminal and click paste) and click enter to run.

Note: This is the first thing you should do once you get into termux.

This would update and upgraded all packages and dependencies and set up your Ubuntu environment.

Once it's done installing and setting up,
Close termux...exit the session entirely(type exit in the terminal and click enter) like this๐Ÿ‘‡



$ exit


Enter fullscreen mode Exit fullscreen mode

then open a fresh session (reopen your terminal)
Then paste and run this command



./start-ubuntu20.sh


Enter fullscreen mode Exit fullscreen mode

This should start up your Ubuntu environment in your terminal
then your termux is fully ready. Your prompt should now look like this:



root@localhost:~# 


Enter fullscreen mode Exit fullscreen mode

Now go and spread forth your favourite linux commands๐Ÿ˜๐Ÿ˜

But wait a litte, after you have set up Ubuntu in your termux, you might experience an issue of not being able to install any package like git or vim(please ignore the following if you can easily install these packages already). This error might be because of the DNS, what you have to do now to solve this is to change your DNS settings in Termux to use a reliable DNS server. For example, you can use Google's public DNS servers.

Just paste and run this command in your terminal and everything should be resolved:



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

Enter fullscreen mode Exit fullscreen mode




PS: If you decide to switch from Ubuntu to any other linux distro, it's very easy, simply just go back into your Andronix app and start from step 2 in this article and click the icon of the distro you wish to switch to.

โšกโšกโšกKindly like and give me a follow if you found this post helpful ๐Ÿ˜Š. If you have any questions, simply drop them in the comment section and i would be glad to answer them. See you next time ๐Ÿ˜‰

Top comments (0)