CodeX
Published in

CodeX

How to Turn Your Android Device into a Full-Fledged Notebook

Yes, You Can Run a Full-Fledged Linux OS On Your Android Device!

Photo by Lauren Mancke on Unsplash

Imagine you are on a lonely Island. With you: Only your Android Tablet and a Bluetooth keyboard. (Tablet or phone capable of multithreading — e.g. Samsung SM-T580 or newer).

How to code with this setting?

In Google Playstore, you won’t find any useful Interpreter nor a Compiler for your programming language (I tried some for Python, Lisp and R — they were not suitable for a developer) nor a full-fledged text or code editor for your programming language of choice (if I err, please tell me that I am wrong in the comments section!). If you want to edit or test your code, read a pdf at the same time, and surf in the internet for code, it seems to be impossible to do this all with your Android device.

As soon as you try to code using your smartphone or tablet, you will realize that a full-fledged OS is a necessity for serious work.

However, there is a solution to do all this in your Android Smartphone or Tablet: Termux!

Termux is a linux shell emulator for Android phones and tablets. It is freely available in Google Playstore.

On Termux, it is possible to install and run a full-fledged Linux OS: Arch Linux for Termux (TermuxArch).

The choice of Arch Linux is thought through well: From all mature Linux distributions, Arch Linux is most efficient in terms of memory footprint. At the same time, it is the best documented Linux Distribution in the internet, while always being most up to date in terms of Linux software (packages in pacman occur usually immediately after software upgrades — while Debian packages — e.g. in Ubuntu — apt — have to wait for the next distribution to be available. (The Arch Linux Community is the quickest in adaption of new software versions). TermuxArch when running within Termuxhas no graphical desktop (X11), but it is possible to get one by running in parallel an XServer program in your Android device and connect it with TermuxArch. By this, you can constitute the illusion of a full-fledged Linux Desktop running inside your phone or tablet, controllable via touch screen OR via a connected bluetooth mouse and a bluetooth keyboard to the phone/tablet.

The procedure is complicated, but possible and it works!

Install Termux

# go to google playstore > Termux > install

Install XServer XSDL

# go to google playstore > XServer XSDL > install

If you start XServer XSDL, you will see a messagelike:

export DISPLAY=192.170.1.100:0
export PULSE_SERVER=192.170.1.100:4713
x-window-manager & firefox
export DISPLAY=:0
export PULSE_SERVER=tcp:127.0.0.1:4713

Write this information down or take a screen shot. We need this information later, to connect the XServer Display with the TermuxArch instance.

Install Git and Subsequently TermuxArch into Termux

You need to install git to install TermuxArch.

The Termux package manager is pkg. To install any available packages into your Termux shell, you type into the shell: $ pkg install <your-package-name>.

To install git, you type in:

$ pkg install git

Git clone the TermuxArch repository into your Termux:

$ git clone https://github.com/sdrausty/TermuxArch

Install the prerequisites for TermuxArch into Termux:

$ pkg install bsdtar
$ pkg install proot

Then, cd into the downloaded TermuxArch folder and install TermuxArch:

$ cd TermuxArch$ bash setupTermuxArch.sh

When successfully installed, the installer stays active in the TermuxArch shell!

Inside the TermuxArch shell, configure pacman which is the package manager of Arch Linux/TermuxArch (which corresponds to apt in Ubuntu):

# add mirror for pacman in arch
# https://bbs.archlinux.de/viewtopic.php?id=14528
$ nano /etc/pacman.d/mirrorlist # (or instead of nano - use your text editor of choice)
# uncomment a server in your country there - for me in Germany
# and save the changes. In nano: `C-x y (or j depending on language)`.

After this, immediately update pacman (these are the corresponding commands for Arch Linux to $ sudo apt update and $ sudo apt upgrade in Ubuntu Linux):

$ pacman -Syy
$ pacman -Syu

Install Programs Necessary for X (for TermuxArch)

Install and start lxde, a lightweight GUI for Arch Linux / TermuxArch:

# install necessities for X:
pacman -S xorg-server
pacman -S lxde # install all!
pacman -S ttf-dejavu

Connect Your Running TermuxArch with XSERVER for a Desktop GUI

Connect lxde with the XSERVER:

# inside your running TermuxArch shell inside termux, 
# give what is desired for connection of X into the TermuxArch terminal:
# (remember, this was the info, which XSERVER displayed before!)

$ export DISPLAY=192.170.1.100:0
$ export PULSE_SERVER=192.170.1.100:4713
# and then start your graphical program
$ startlxde
# after this, change to the XSERVER screen
# you will see the running ArchLinux Desktop there!

Voila! Your LXDE should start in the XSERVER screen, and using a bluetooth mouse and bluetooth keyboard, it should feel like having access to a full-fledged OS with GUI inside your Android device!

The most important difference to Android and Termux is: Now you can install any pacman-installable Linux software inside your TermuxArch — which are neither Android apps nor Termux packages — but normal Desktop (Arch) Linux Software. — Inside TermuxArch, you can install any Linux software you want and need for your programming — you are not dependent on available Android apps any more! — Isn’t it an ingenious hack?

# e.g. to program lisp using emacs and sbcl, I installed:
pacman -S sbcl
pacman -S emacs

The only restriction, however, is that these programs have to be built for your Tablet’s architecture and available in pacman at the same time. In addition, the memory footprint of the programs should not exceed your RAM in your device.

With this setting (TermuxArch in Termux with XSERVER), I could:

  1. Open a PDF book for programming
  2. Run Emacs side by side to take notes
  3. Run even an interpreter for the language (sbcl) connected to Emacs so that I could test my code which I was writing down.
  4. And even browse in the internet to search for functions in the programming language of choice — since Firefox or Chrome would occupy too much RAM I pacman-installed some browser with thin memory footprint: Pale Moon.

(If you are a Mac iPad or iPhone user, you might find equivalent functionalities in iSH which comes closest to Termux for the Mac. Please write into the comments, if you tried it — or leave a link to your medium article about this :) )

Happy coding! — Enjoy your transformed Android device with notebook functionalities!

--

--

--

Everything connected with Tech & Code. Follow to join our 900K+ monthly readers

Recommended from Medium

Finding Articulation Point(Cut Vertex) in a graph

How To Obtain Grain Rates With A JSON API

What is a checksum?

Creating Cards With Grid Layout

Get Started with Docker Lifecycle

dockers caching layer with COPY and globs

JLPT N4 Grammar-ながら Nagara (How to say “While…” in Japanese)

The Ultimate Guide To Coding Interviews

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gwang Jin Kim

Gwang Jin Kim

Code tweaker + Human Geneticist (Ph.D.) | Join medium by: https://gwang-jin-kim.medium.com/membership

More from Medium

How to Add a Database to a Website

Automating Google Drive Uploads With Google Drive API & cURL

How I Use A Telegram Bot To Track My Expenses

The importance of writing clear docstrings in programming