Linux Fu: The Linux Android Convergence

The Android phone that you carry in your pocket is basically a small computer running Linux. So why is it so hard to get to a usable Linux environment on your phone? If you could run Linux, you could turn your cell phone into an ultra-portable laptop replacement. Of course, the obvious approach is just to root the phone and clean-slate install a Linux distribution on it. That’s pretty extreme and, honestly, you would probably lose a lot of phone function unless you go with a Linux-specific phone like the PinePhone. However, using an installer called AnLinux, along with a terminal program and a VNC client, you can get a workable setup without nuking your phone’s OS, or even having root access. Let’s see what we can do. AnLinux AnLinux takes advantage of the fact that Android is really Linux underneath. It lets you mount an image file that contains a root file system from any of several distributions including Ubuntu, Kali, Fedora, CentOS, OpenSuse, Arch, Alpine, and others. In addition to creating a script that does a chroot to “mount” the image, the installer also uses PRoot to simulate root access. PRoot intercepts any calls you make that would normally require root access and makes them work in the current context. It uses the ptrace system call to effectively debug your software in order to do this. With PRoot, you can do things like a chroot without being root and PRoot also provides fake user permissions on your pseudo-file system. AnLinux itself isn’t a big program. It installs operating system images and creates scripts that can start the environment for you. Then you’ve got a fake Linux computer running inside your Android phone while Android is still running. Simply connect to it from the outside Android OS using a terminal program or a VNC viewer, and you’re good to go. Sounds kludgey, and it is, but it also works. Is it perfect? No. Some things need real root access to work. But it does work surprisingly well if you temper your expectations. What You Need Obviously, you are going to need an Android device. It must run at least Lollipop, but it can be a 32- or 64-bit Arm or x86 device. You’ll also need a lot of free storage for the disk image, so an SDCard or a big device is pretty important. You’ll also need: AnLinux (easy to install from Google Play) Termux (also on Play) VNC Client (I suggest VNC Viewer) Bluetooth keyboard (optional) Bluetooth mouse (optional) HDMI output cable for your phone (optional) Termux and VNC Client are all you really need to access the fake Linux box. The last three items are creature comforts. You’ll probably be happier with an external keyboard, even if it is a tiny foldable one. Bluetooth keyboards are the simplest way to go, although you could probably also use a USB host cable and a hub to plug in USB devices, but that’s less portable and I haven’t actually tested that theory. An HDMI output cable gets you connected to a big display if you aren’t happy with your device screen. Still, the VNC client can zoom in and out, so it is workable without an external screen. At the least, you should have a kickstand or holder to keep the phone upright. About the only hitch I’ve found is that the cables for video output don’t charge my phone at the same time, leaving it running on batteries. This isn’t true of all phones and maybe even not of all cables, so you might want to check if you can charge at the same time for longer sessions. Getting Started Once you install Termux, you can use it to get a normal terminal into your Android device. You aren’t root — well, you could be if you rooted your device, but I’ll assume you haven’t. The next order of business is to install an image for a Linux distribution. To do that, open AnLinux and select the Dashboard from the menu. There are three buttons, but you’ll only be able to press the first one. When you push that button you can select what distros you want to install. It is possible to install more than one, but you’ll need lots of storage and you’ll have to repeat the steps for each one you want to install. Once you select your distro, the other two buttons will light up. The second button lets you load the clipboard with the commands needed to download and install the Linux system. That will typically be some pkg commands, some wget commands, and a shell script to execute. The third button launches Termux so you can paste the commands in the terminal window. Once it completes, you’ll find a shell script that allows you to launch the distro environment. The install will be minimal to save space. There are similar button setup screens to enable an ssh server, and set up various desktop environments. Once you’ve done the install, you don’t have to repeat it. You can simply open Termux and run the shell script to launch your fake Linux system. Get Graphical If you want to run a graphical environment, you just have to select the menu for desktop environment and push more buttons. Your choices will vary based on the distribution you are using. For Ubuntu, for example, you can select Xfce4, Mate, LXQt, or LXDE. You can do a similar set of steps to pick your favorite window manager, for example, Awesome or IceWM. To start, you’ll have to use the script that the installer leaves to launch the distro. Then there’s another script to start a VNC server. The names of the scripts depend on what you install, but the AnLinux installer will tell you what you need to know. After launching the VNC server,  you connect your VNC viewer to the specified port the script mentions on the localhost address, and you’re inside the virtual Linux machine. Performance on my Pixel 2XL is really not bad, although it won’t replace my giant Linux desktop by any means. Not a Toy This might seem like a toy and, as I’ve said, it isn’t going to replace a real Linux box for most people. But sometimes you need to pull over on the side of the road and log into a server. Having a complete set of tools that you are used to can be helpful. Can you just install something like JuiceSSH and connect to the remote box directly? Of course. Or use VNC with a remote server. But if someone sends you an OpenOffice spreadsheet you need to look at on your phone and you want to use sshfs to mount your remote drive full of macros at the same time, this is the solution. If you carry a small portable monitor, a keyboard, and a mouse, this could also stop you from having to lug around a laptop as much, too. Even more so when you are somewhere you can borrow all of those items. Sure it is a compromise, but it is workable and often better than having nothing with you.

Linux Fu: The Linux Android Convergence

Published by Suleimanmuhammad


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with
Get started
%d bloggers like this: