DEV Community

Nicholas Synovic
Nicholas Synovic

Posted on

Guide to replacing a laptop with Android: Part 2

Time to set up a Linux container on top of Android OS.

This is significantly easier than I expected. Going pack to the zeroth post in this series, I am shocked at how far the community has pushed Android OS to become a desktop replacement OS.

Some of this work was undertaken by corporations. This is most clearly shown by Samsung Dex, a desktop skin of Android that is installed on most of Samsung's latest devices. It is still Android under the hood, and it isn't perfect either, but it provides a basic, Chromebook-Esque interface to Android. This software package is partly the reason why I chose the Samsung Galaxy S7 Tab as well.

The two apps to start developing in a Linux container on Android OS are:

To be honest, you don't need AndroidNix to get this working, but it certainly helps.

What is Termux?

Termux is a free and open-source terminal emulator for Android OS. More importantly, it comes bundled with many of the GNU Core Utils and a package manager that wraps around apt. This allows for the downloading and installation of software that has been specifically compiled to run on Android and AARCH x64 devices from the shell.

The major downside with Termux is that most software has to be ported to run on Android. Some software packages run completely fine on Android without any porting process, however, most programming languages do. Luckily, the community that supports Termux is constantly filing issue requests on GitHub to add new software and implement ports of the software into the Termux repositories.

But for what we are doing, we won't be relying on Termux's package management solution that much. Rather, we will be using AndroidNix.

How do I install Termux?

  1. Download and install F-Droid on your Android device.
  2. Within the F-Droid app, search for Termux.
  3. Download and install Termux via the F-Droid app.

The F-Droid app is necessary as the Google Play version of Termux is out of date.

If you are uncomfortable with installing a 3rd party app store on your device, you can read more about how to install Termux here.

What is AndroidNix?

AndroidNix is a collection of scripts that allow for the creation of a Linux container inside of a [proot](https://proot-me.github.io/), a userspace implementation of [chroot](https://en.wikipedia.org/wiki/Chroot). They also have a GitHub page where you can examine the scripts that they run. But to make life a lot simpler for us, we will be using their Android app which offers a user-intuitive way to select a distro and (if you want) a desktop environment or window manager.

This app simply copies the command necessary to install the proot to your device's clipboard and then you have to run that in Termux.

How do I install AndroidNix?

  1. Open the Google Play Store app on your Android device.
  2. Within the Google Play Store app, search for AndroidNix.
  3. Download and install AndroidNix via the Google Play Store app.

How do I set up a Linux container on Android OS?

Simple Install

I am working on a GitHub repository to set up a Termux Linux container exactly as I want it. You are more than welcome to use my [install.bash](https://github.com/NicholasSynovic/termux-linux-container/blob/main/install.bash) script to install Ubuntu 20.04 with the XFCE desktop environment.

How to run this script

  1. Download it from GitHub
  2. In Termux, execute chmod +x install.bash
  3. In Termux, execute ./install.bash

Notes

This install script only installs the Linux distribution. It doesn't change any system settings or install any non-default software.

This install script is not automated and does require user input in its current form.

Manual Install

  1. Open AndroidNix, select your OS, desktop environment, or window manager (if desired), and then click the "Open Termux" button.
  2. Paste the command in your clipboard and then press your Enter key to execute the command.
  3. Follow the onscreen prompts to complete the installation.
  4. (Optional) After installing, run yes | unminimize to install any remaining software not explicitly set up or installed during the normal installation.

How to view the desktop environment of my Linux container?

  1. Download the VNC Viewer app from Google Play Store.
  2. Create a new connection to localhost:PORT where PORT is the port number you specified in your setup.
  3. Connect to the desktop environment.

If your desktop environment is laggy or slow, try changing the connection quality to High in VNC Viewer.

How do I stop/ start a VNC server in my Linux container?

  • To stop a vnc server: vncserver-stop
  • To start a vnc server: vncserver-start

How to stop the Linux container?

In the Linux container: exit

How to start the Linux container?

In Termux: ./start-ubunutu20.sh

Conclusion

Congrats! You have created a Linux container on top of Android OS. You and I are on our way to getting rid of our hefty laptops once and for all and doing all of our work truly from the palms of our hands. Assuming you have a big enough hand to palm an Android tablet that is.

But this was the easy part. Currently, we still have to deal with:

  • No installed IDE or text editor
  • No installed programming languages
  • No installed desktop software

And, most scary of all:

  • Everything runs as the root user

All of this and more will be covered in later tutorials.

I hope that this is useful to someone.

Signing off,

Nicholas M. Synovic

Discussion (0)