Install the Linux desktop on Android

Hello, Habr! I present to you the translation of an article from APC magazine.

image

This article discusses the full installation of the Linux operating environment along with the graphical desktop environment on Android devices.

One of the key technologies that many of Linux systems on Android use is pRoot . This is a user-space implementation of the chroot utility, which is very popular on Linux desktops and servers. However, the chroot tool needs root user privileges, which are not available by default on Android. pRoot gives this advantage by establishing a binding to the directory.

Linux terminals


Not all Linux terminal emulators for Android have a set of BusyBox utilities, unlike, for example, Termux. The reason for this is the fact that the whole point of such systems is to provide a “complete” installation of all OS components, while BusyBox is designed to reduce all the many common utilities into a single binary file. On systems where BusyBox is not installed, bootstrapping for Linux is used, which contains full versions of programs.
"

Set the login and password for the distribution and VNC in UserLAnd.

However, these systems have additional technology that does not require Termux. This article will cover the full installation of the Linux distribution, as well as the GUI desktop. But first you need to choose the installation method of the graphics system.

Linux on Android


As mentioned earlier, the software packages that we will install run in user space.

This means that they only have permission for the current user, which in the case of Android OS is always a regular user, i.e. does not have administrator privileges. However, in order to install the Linux desktop, we need to install a graphical server, for example, X or Wayland. If we did this in the Linux operating environment, then it would start with the privileges of a regular user, without having access to the graphical level of the Android OS. And therefore, we should look towards installing the server in the “standard” Android way, so that it has access to hardware and the ability to support the graphical environment.

Smart guys from the developer community have proposed two solutions to this problem. The first is to use your own version of Linux (usually an X server). After they start working in the background, you will have access to this background process through VNC. If your Android device already has a VNC viewer program for interacting remotely with other computers, just use it to gain remote access to the local host. This is an easy-to-use solution, but some users report experiencing difficulties with the program.

The second option is to install a server designed specifically for Android devices. Some servers are available on the Play Store in both free and paid versions. Before installation, you need to check whether the selected option is supported or at least works with the Linux software package for Android that you are going to install. We preferred the X-Server system, and therefore used the XServer XSDL software package ( link ). The article will describe the installation process for this server, although it may be slightly different if you have another application installed or are using VNC.

System selection


As in the case of X-Servers, there are several applications for installing Linux system distributions in the Play Store. Here, as with Termux, we will concentrate on options that do not require superuser authority, which in turn involves a certain degree of risk. These applications provide all the functionality necessary for most users, while keeping your data safe. The following are examples of such applications on the Play Store:

- UserLAnd : A very popular choice of users. The application includes a set of common distributions: Debian, Ubuntu, Arch and Kali. Curiously, despite the lack of RPM-based options, UserLAnd includes Alpine Linux for devices with less memory.

- AnLinux: This application helps in installing one or more large-volume distribution lists and may include Ubuntu / Debian, Fedora / CentOS, openSUSE, and even Kali. There you can also choose low-cost desktop options: Xfce4, MATE, LXQtand LXDE. To work, you need installed Termux, and the Android operating system must be from 5.0 and above.

- Andronix is very similar to AnLinux. It may have a better design than the previous application, but it supports fewer distributions.

- GNURoot WheezyX: This project started as a Linux variant on Android and was developed for open source programs. As the name suggests, it focuses on Debian distributions, while the 'X' at the end means that the application is focused on the graphical desktop. And despite the fact that the creators stopped the development of the project for the sake of UserLAnd, GNURoot WheezyX is still available on the Play Store, if anyone has a need for it.

The authors of this article will use the UserLAnd application to install the Linux desktop on Android, and there are several reasons for this. Firstly, the application is open source (although AnLinux also has it). Secondly, it offers a good set of distributions (although Fedora or CentOS are not included in it), it is also possible to install distributions with the minimum system requirements that will not take up much space in the smartphone’s memory. But the main advantage of UserLAnd is that it has support tools for installing individual applications instead of entire distributions. We will find out what exactly this means for us, later. Now let's install UserLAnd on your device.

UserLAnd Application


Download the application from Google Play or F-Droid ( link ) on the Android OS. It is installed like any other application - nothing special needs to be done here. After that, launch it from the application panel.

The first thing you will see there is a list of distributions. At the end, you can find a couple of desktop options: LXDE and Xfce4. Closes his application Firefox, a couple of games and several office utilities: GIMP, Inkscape and LibreOf fi ce. This tab is called “Applications”. It is designed to install applications.

After you install something, a corresponding entry will appear on the Session tab. Here you can start or stop the current session, as well as see the running processes.

“Filesystems” is the last tab that shows already completed installations. It is worth noting that after you delete any item from Filesystems, information about it will be erased from the Session tab, which, however, does not prove otherwise. This means that you can create a new session based on the current file system. Understanding how this relationship works is much easier if you see it in action, and therefore we will start by installing the application in the UserLAnd system environment.


Before you install the distribution on your smartphone, you must provide UserLAnd access to the repository.

Distributions in UserLAnd


Select one of the distributions located on the Apps screen to install on the device. As an example, we will use Ubuntu. When you click on the icon, a dialog box appears asking for the VNC username, password and password. Then select the way in which you will access the distribution. The download will begin, during which the base image of the selected distribution will be involved. The file will be unpacked in the UserLAnd directory.

When the download is complete, return to the xterm terminal emulator. You can enter a utility command to find out which version of Linux you installed:

uname –a

The next step is to install the desktop using the Ubuntu utility command:

sudo apt install lxde

The final step is to make sure your new desktop environment is ready to run. To do this, you need to edit the .xinitrcfile file, which currently has only one line / usr / bin / twm . It must be changed to / usr / bin / startlxde. Now exit the XSDL session (be sure to press the STOP button in the notification area), hold the “Ubuntu listing” button on the Sessions tab, then click “Stop Sessions” and restart the sessions. After a few seconds, the LXDE system environment should appear. You can do the same in it as on a regular desktop. It just might be a little smaller and work a little slower: to press a button on the device, you have to wait longer than if you did it with a keyboard and mouse. Let's see how exactly we can improve the Linux system environment on a smartphone.

UserLAnd Quick Guide


A careful study of the contents of the desktop, you can find the exact recreation of the desktop version. If you use UserLAnd on a device with a keyboard and mouse (connected via a Bluetooth connection or in some other way), it will be easy for you to adapt to using the Linux system environment in this format. With the exception of a slight lag due to the fact that the X-Windows cursor is synchronized with the cursor of the device on Android, everything works smoothly.

Perhaps the first thing you want to do is adjust the default font system, since the desktop font size is too large for the phone screen. Go to the main menu, then select "Settings" → "Customize the appearance and widgets" → "Widget". Here you can change the default font size to a more suitable option for your phone.

You may want to install your favorite programs in the Linux system environment later on. As mentioned above, utility commands will not work in this case, so feel free to use the truly irreplaceable tool that is installed in the UserLAnd system environment, called ASAP:

sudo apt install emacs



Distributions in the application are presented in the form of sessions. You can start and close them.



After installing the distribution, you can add a desktop environment with standard commands.

You will probably also need alternative ways to establish a connection for your distribution. The fact that you originally installed XSDL does not mean that it should be unchanged all the time. You can create another account on the Session tab and select another server. Just be sure to specify it on the same file system. UserLAnd will try to direct you to the desired application to establish a new type of connection: either XSDL, ConnectBot for SSH, or bVNC.

However, the persistence with which the application automatically directs you to the Play Store when trying to reconnect can be annoying. To stop this, just change the server by installing a special application. To install SSH, select the old proven VX ConnectBot. Just enter port 2022 on your workstation with your username and password. To connect to the VNC server, it’s enough to install the commercial, but in many ways advanced Jump Desktop application, and dial the address 127.0.0.1►951.

We hope you remember the VNC password that was set when you created the file system.
You can also access the current UserLAnd session using similar tools on another computer on your network. It is enough to connect SSH to a working session (with an SSH connection type, of course) using a Linux terminal, for example, Konsole, or connect to a VNC session using KRDC. Just replace the local addresses on the computer screen with the IP addresses of your Android.

Combined with a pair of portable applications, this installation will give you a handy portable Linux system that you can connect to using any computer that is currently available to you.

All Articles