APC Australia

Running the Linux desktop on Android

Aaron Peters takes the Linux-on-Android concept a step further by cramming a full desktop onto an Android Phone.

-

In this article we’re going to install a fully-featured Linux environmen­t, complete with graphical desktop, onto your Android device.

One of the key technologi­es many of these systems employ is pRoot (https://proot-me.github.io). This is an implementa­tion of the chroot utility that’s popular in the desktop/server Linux world. But chroot requires root privileges, which aren’t available by default on Android. So pRoot provides most of the benefits of chroot by doing some clever directory binding.

CHECK THE BELOW

Unlike Termux, however, not all of these Linux-on-Android systems use BusyBox (https://busybox.net). The reason is because the whole purpose of these systems is to provide a ‘full’ installati­on, whereas BusyBox is designed to wrap up a number of common utilities into a single binary. Instead, these systems install a typical Linux bootstrap containing the full-strength versions of programs like ls, cp and mkdir.

There is one bit of additional technology for these systems that wasn’t required for Termux, however. We’ll be installing a full-strength Linux distro, which brings with it the expectatio­n of a GUI desktop. We will get one of these, but in order to do so we’ll need to make an important decision regarding the graphics system.

LINUX-ON-ANDROID

As we’ve said a few times, the packages we’ll be looking at, as well as some others, run in userspace. This means they only have the permission­s of the current user, which in the case of Android is always a normal user –that is, not root. However, in order to enable our Linux desktop, we’ll need to be able to install a display server such as X or Wayland. If we did that in our Linux environmen­t, it would run with the normal user’s permission­s, which don’t include access to Android’s graphics layer. So we’ll need to look at options that install one of these servers in the ‘standard’ Android way in order to access the hardware, and will also provide a supported graphical environmen­t.

The clever folks in the developmen­t community have come up with two solutions. One is to use the native Linux versions (typically X rather than the newer Wayland). This will start up and run in the background, and you’ll then access this background process over VNC. If you already have a VNC viewer on your Android device for remoting into other machines, you’ll basically just use that to remote into the local host. It’s a straightfo­rward solution that’s easy to set up, although some users report issues with performanc­e and lag with this setup.

However, a second option is to install a display server designed for Android. There are several of these available in the Play Store, both paid-for and free. The most important thing to check is whether it’s supported, or at least has been known to work, with whichever Linux-on-Android package you choose. We favour the X-Server approach, and we’ve used the XServer XSDL package (http://bit.ly/lxf256xser­ver) in the past with no issues. We’ll describe that here, although the process may be slightly different if you settle on another app, or use VNC instead.

SELECTING A SYSTEM

As with X-Servers, there are multiple options in the Play Store that provide the Linux system we’re seeking. Here too, as with Termux, we’ll be focusing on solutions that don’t require you to ‘root’ your device. This carries a degree of effort and risk that’s kind of hard to justify. These non-root solutions provide all the functional­ity most users will need, without the chance of ruining your warranty. Here are a few of examples of these apps in the Play Store:

■ UserLAnd (http://bit.ly/ lxf256user­land): This popular option installs a number of common distros, including Debian, Ubuntu, Arch and Kali. Interestin­gly, while it doesn’t include any RPM-based options, it does include Alpine Linux for devices with less space. AnLinux (http://bit.ly/

■ lxf256anli­nux): This app assists in installing one (or more!) of a sizeable list of Linux distributi­ons, which includes Ubuntu/Debian, Fedora/ CentOS, openSUSE and even Kali. You can also select from a couple of low-resource desktop options including Xfce4, MATE, LXQt and LXDE. It does require Termux to be installed. It also requires a device running Android 5.0 or higher. Andronix (http://bit.ly/

■ lxf256andr­onix): Very similar to AnLinux. It has arguably a nicer design, but supports a smaller set of distros.

GNURoot WheezyX (http://bit.ly/

■ lxf256gnur­oot): The GNURoot project started as a Linux-onAndroid option focusing on open source software. As the name suggests, it’s focused on the Debian distributi­on, while the ‘X’ at the end signifies this app is targeting a graphical desktop. While its developers have gone on to create UserLAnd, it’s still available in the Play Store if it fits your needs. We’ll be using UserLAnd for this tutorial, for a couple of reasons. Firstly, it’s open source (although so is AnLinux). It offers a good selection of distributi­ons, and although these don’t include Fedora or CentOS, they do install a couple of options to produce a very minimal system that won’t take up a lot of precious storage. But mostly, UserLAnd has support for installing apps instead of entire distributi­ons. We’ll explore exactly what this means in a later section. But for now, let’s get UserLAnd onto your device.

INTO THE USERLAND

The first step to getting this system spun up on your Android device is to install the app from Google Play or F-Droid (https://f-droid.org/en/ packages/tech.ula). This installs just like any other app – you’re not doing anything special just yet. Once the installati­on is done, you can launch it from the app drawer just like anything else.

The first thing you’ll see is a list of distributi­ons, and we’ll get to those. But if you scroll down a bit, you’ll come to a couple of desktop options: LXDE and Xfce4. Bringing up the rear are a list of apps, including Firefox, a couple of games, some utilities for developmen­t such as Git and science (GNUPlot), and some nice office apps: GIMP, Inkscape and LibreOffic­e. You may notice at this point that you’re on a tab called Apps. You can think of this as holding the stuff you can install.

Once you’ve installed something, you’ll see an entry for it on the next tab, which is Sessions. From here you can start or stop it, as well as see what’s already running. Filesystem­s, the last tab, shows the installati­ons you’ve already done. These two work together to allow you to control the ‘processes’ within UserLAnd as well as the installati­ons. It’s worth noting that when you delete something from Filesystem­s, its correspond­ing session will disappear, but the opposite isn’t true. You’re able to create a new Session based on an existing Filesystem, for example to be able to access it via VNC in one Session, and with XSDL in another.

Understand­ing this relationsh­ip is easiest when you see it in action, so we’ll begin by installing just a single app in the UserLAnd environmen­t.

APPS IN USERLAND

If you scroll to one of the applicatio­ns such as Inkscape in the list on the Apps tab and tap it, you’ll begin the installati­on process. When you select an app, a dialogue appears asking you to select what method you’ll use to access it. With a GUI app like Inkscape, you can select either VNC or XSDL. As mentioned previously, we’re using the latter for this exercise, although they’ll both work. Next, the app requires access to your internal storage, and will ask you for that permission. This is because UserLAnd will be downloadin­g your selection and needs temporary storage before moving it to the protected part of the phone.

If you selected XSDL as the access method and haven’t installed it yet, you’ll be forwarded to the Play Store where you can pick it up. Once XSDL is installed it will launch, and after a few moments you’ll be in an X-Windows environmen­t that will be familiar to old-school users (rocking the TWM window manager, for those who are cool). No background image, no fancy desktop menus or docks, just an xterm window. You’ll see commands start to scroll through this window, though if you’re on a phone they may be so small that they’re hard to read. But this is the installati­on of your app, using standard Linux package tools. App-only installati­ons use a Debian base, so here apt is duly installing the program you selected along with its dependenci­es.

Finally, once it’s complete the program’s window will appear. Tap to finalise its placement and the window will render, along with the menus and buttons you’d see on the desktop version.

There are a couple of things to keep in mind once the app launches. First, there’s only a simple window manager controllin­g the placement of the window in relation to other windows. There’s no nice, consistent treatment of things like fonts and images that you’d get with a full desktop environmen­t. As you can see in the screenshot of Inkscape, the font in the menu bar is larger than the proportion­al treatment of the buttons. In addition, some dialogues or other elements will be developed with bigger screens in mind. So they’ll appear very large, maybe too large to even be of use. In Inkscape on the our phone, for example, the ‘Open file’ dialogue is so large that most of the controls aren’t accessible at first. You can fix this with keyboard-based commands to control windows, but it may present a bit of a challenge until you get the hang of it.

As a quick way to make a tweak to some file this may be sufficient, but let’s see if we can get a better experience by installing a full desktop.

DISTROS IN USERLAND

From the Apps screen, select one of the distributi­ons to install on your device. We’ll use Ubuntu as our example here. Tapping it brings up the same dialogue as before, asking for a username, password and VNC password. You’ll then select the method with which you want to access it, including the two prior options as well as SSH. The download will begin, this time fetching a base image for the distro you picked and unpacking it into UserLAnd’s directory.

When it finishes, you should return to the XSDL ‘desktop’, and presented with an xterm window. You can issue a

standard command to check what your Linux version is: uname -a

The next step along to a desktop is to install it, again using standard Ubuntu commands: sudo apt install lxde

You can also use xfce4 if that’s more your speed. Cue more downloadin­g and installing… when you get to the prompt again, just use the following to start up your swanky new desktop: startlxde

The last step is to make sure that your new desktop environmen­t is the one that starts on launch. To do this, you’ll need to edit your .xinitrc file; it currently has a single line of /usr/ bin/twm . You just need to change this to /usr/bin/startlxde . Now exit out of the XSDL session (make sure you hit the STOP button in the notificati­on area), long-press on the Ubuntu listing in the Sessions tab and hit Stop Sessions, then restart everything. You should see the LXDE desktop come up after a few seconds. Subject to some of the caveats we’ve discussed previously, you can do just about anything in this environmen­t you could do on a desktop. It just might be a little smaller, a little slower, and take longer to tap into your device than it would be with a keyboard and mouse. Let’s take some time to explore exactly what you can accomplish using a device.

ROUGH GUIDE TO USERLAND

If you take some time to click around the desktop, you’ll find it’s a faithful recreation of the desktop version. If you’re using UserLAnd on a device with a keyboard and mouse (Bluetooth or otherwise), you’ll find it easy to get around. Aside from a little lag as the X-Windows cursor tracks your Android device’s cursor, everything works easily.

In this case, your screen is the trackpad: rather than tapping directly on what you want, slide instead to move the on-screen cursor, then tap the screen to click (two-finger tap for a right-click). If you need to input some text, press the Back button on your device. This will bring up (Android’s) virtual keyboard. Hit the Back button again to close it; the screen will ‘bump

up’ out of the way, then return once you’re done.

The first thing you may want to do is to adjust the default system font, as the desktop size is still pretty big on phone screens (no worries if you’re on a tablet). Head to the main menu, then go to Preference­s > Customize Look and Feel > Widget. Here you can set the default font size to something more manageable: 6 pt makes things look pretty nice on a Note 5.

Obviously, the next thing you’ll want to do is start installing some of your favourite programs into your new Linux environmen­t. As shown above, the standard commands will do the trick here, so feel free to get the one truly indispensa­ble tool installed in your UserLAnd environmen­t ASAP: sudo apt install emacs Another thing you may want to consider is setting up alternativ­e connection methods for your distro. Just because you initially installed it for an XSDL connection doesn’t means it needs to remain that way. You can create another entry in the Session tab and select a different connection method. Just make sure you point it at the same Filesystem. UserLAnd tries to direct you to the correct applicatio­n to handle the method you’ve chosen: either XSDL, ConnectBot for SSH, or bVNC.

Unfortunat­ely, it’s rather insistent that you at least try these, as it will shuffle you off to the Play Store automatica­lly to install them. However, you can back out of this, and connect using the app of your choice. For SSH, we rely on trusty old VX ConnectBot. Just log into port 2022 on localhost with your username and password. For VNC, the proprietar­y but thoroughly excellent Jump Desktop works like a charm by pointing the VNC connection at 127.0.0.1:5951. Just hope you remembered the VNC password you set up when you created the Filesystem…

Note that you can also access your running UserLAnd session using similar tools on another machine on your network. For example, you could SSH into a running session (with the SSH connection type, naturally) using a Linux terminal like Konsole, or connect to a VNC session using KRDC. Just substitute the localhost addresses above with your Android’s IP address. Paired with a couple of portable apps, this setup gives you a handy little portable Linux system you can jump into using whatever machine happens to be available at the time.

And that’s really all there is to it

– so load up and get hacking on your mobile device!

 ??  ?? Set up either an App or Distro in UserLAnd with a username and password, plus one for VNC.
Set up either an App or Distro in UserLAnd with a username and password, plus one for VNC.
 ??  ?? Installing one of the Apps will let you launch straight into it from UserLAnd.
Installing one of the Apps will let you launch straight into it from UserLAnd.
 ??  ?? Before you can get any of the good stuff on your phone, you will need to give UserLAnd access to storage.
Before you can get any of the good stuff on your phone, you will need to give UserLAnd access to storage.
 ??  ?? UserLAnd provides a small number of standalone applicatio­ns for installati­on.
UserLAnd provides a small number of standalone applicatio­ns for installati­on.
 ??  ?? Once you have a distributi­on installed, you can add a desktop environmen­t with the usual commands.
Once you have a distributi­on installed, you can add a desktop environmen­t with the usual commands.
 ??  ?? Installed Apps and Distros are represente­d as Sessions to start and stop.
Installed Apps and Distros are represente­d as Sessions to start and stop.

Newspapers in English

Newspapers from Australia