Linux on Android phones

Introduction and limitations

⯈ The take-home message is this : you can do your unix and programming exercises on your android phone/tablet. By following the instructions given below (a) you will install a minimal linux-like environment on your phone in the form of a normal android application, (b) nothing bad will happen to your phone/tablet (it is just another app you've installed), and, (c) everything is completely free, you will not have to pay a dime.

⯈ The limitations are :

(a) The procedure below will only work with recent versions of android (version 5 and later). This is probably true for all phones made after 2014.

(b) The phones usually have small screens and if the virtual keyboard takes half the screen, you'll be left with very little space to work (see screenshots with virtual keyboards below). You can work with the on screen keyboard if you are determined enough (or you have an android tablet), but do consider the possibility of buying an external keyboard. Prices for USB or Bluetooth external keyboards start at about 9 euros. Not all keyboards on the market are compatible with each and every phone out there, so if you decide to buy one, do try to choose a keyboard that works with your phone (ask your local android guru for advice).

(c) There are some differences between a proper linux installation and what you'll get on your phone, but they are minor differences that will not stop you from learning what you need to know about the unix shell and to do some simple programming with C and perl (and python and nodejs if you want).

Step 1 : Get termux from google play

All the steps that follow must, of course, be performed from your phone (and not, for example, the laptop that you may be using for reading this). It is also assumed that you have access to the network (wifi or 4G).

⯈ Go to

and install termux. Termux is free and doesn't contain advertisements of any kind.

Step 2 : Setup the files and programs needed for the exercises

⯈ Start termux (the app you've just installed). You should see something like this :

alt Initial screen

⯈ Copy-paste (and then press ENTER) the following line in termux (if you long-press on the screen, termux will give you the option of pasting a line) :


You should see something like this :

alt wget

⯈ Copy-paste (and then press ENTER) the following line in termux :


At first you will see something like this :

alt source

and after many lines are printed, you'll see this :

alt source_end

⯈ Close/kill/exterminate the unix shell (termux). The proper way to do this is to type exit and then press ENTER twice. Now, rotate your phone to landscape mode and -after rotating it- open the unix shell again. You should see something similar to this :

alt source_end

You can increase/decrease the font size by using the usual zoom-in/zoom-out screen gesture.

Step 3 : Keyboard woes

At this point everything is installed, but in order to test things you will be needing a keyboard that has all the special keys like CTRL, ESC, ALT, arrow keys, etc. If you have an external (physical) keyboard you don't need to do anything, so skip to the next section of this document. If you can't avoid suffering with the virtual (on screen) keyboard, keep reading.

There are two solutions :

⯈ The first is the easiest, it doesn't require the installation of any additional packages and it is based on using the default android keyboard with some help from termux itself. Do the following : (a) Open termux, (b) touch the screen (so that the default android keyboard appears) and then (c) press (and keep it pressed) the Volume-Up key (at the side of the phone) and simultaneously press the key 'Q' on the keyboard. You should see a new set of extra keys appearing. It will look something like this :

alt source_end

⯈ The second solution is to install a proper full size virtual keyboard (see screenshots below), but this requires the installation of an additional package. To do this proceed as follows : To get a proper virtual keyboard (with all the special keys), go to

and download and install the APK file (locate the point that says Download APK 1.2 MiB). If you don't know how to install APKs, ask a nerdy friend of yours for help.

You should now have yet another keyboard to choose from (named 'Hacker's keyboard'). It is time to test things-out. Turn the device landscape, open the unix shell (termux), touch the screen, select the new keyboard (you select keyboard from the small icon that looks like a small keyboard). You should see something like this :

alt source_end

You can see the problem mentioned in the introduction : half the screen is gone, and too little space is left for doing any actual work. Having said that, ανάγκα και θεοί πείθονται : If you must work with the virtual keyboard, you will work with the virtual keyboard.

If you are confident that you can type on any keyboard no matter how cramped, you can actually test your typing skills by using hacker's keyboard in portrait mode :

alt source_end

Step 4 : Testing the installation

Close any old unix shells you may have, and open a fresh one. Try a few commands and compare the output (don't ask me what to type, see the image below, compare with your screen and you'll get it) :

alt source_end

Test that the 'nano' editor works as expected with both C and perl. Type 'nano test.c' and you should see something like this :

alt source_end

Press CTRL-X to exit nano. Similarly, view the perl program with 'nano' [the last letter in is an L (from PerL)] :

alt source_end

Test that the programming environment works as expected (after typing the 'gcc test.c -lm' command you press ENTER. Nothing should be printed on your screen) :

alt source_end

and press ENTER after you've typed the last command shown. You should see something like this :

alt source_end

Press the Q key (for quit) to exit 'less' and return to the shell. Finally, test that perl works :

alt source_end

You are done. Close everything and go back to bed.

Step 5 : You want to use VIM ? Seriously now ?

Well, if you want to use vim, then you'd better be able to do all the typing required. If you don't know what I'm talking about, stop here.

Here are two screenshots just so you know what to expect :

alt source_end

alt source_end