Install Linux desktop on Android

Hey Habr! I present to your attention a translation of an article from APC magazine.

Install Linux desktop on Android
This article covers the complete installation of the Linux operating environment along with the graphical desktop environment on Android devices.

One of the key technologies that many of the Linux systems on Android use is pRoot. This is a userspace implementation of the chroot utility that is very popular on Linux desktops and servers. However, the chroot tool requires root user authority, which is not available by default on Android. pRoot, on the other hand, gives this advantage by establishing a directory affinity.

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 "full" installation of all OS components, while BusyBox is designed to bring all the many common utilities into one binary file. On systems that do not have BusyBox installed, the bootloader for Linux is used, which contains the full versions of the programs.
Install Linux desktop on Android"

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 a complete installation of a Linux distribution as well as a GUI desktop. But first you need to choose a way to install the graphics system.

Linux on Android

As mentioned earlier, the software packages we will be installing 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 normal user, i.e. does not have administrator rights. However, in order to install a Linux desktop, we need to install a graphics server such as X or Wayland. If we did this in the Linux operating environment, then it would start as a normal user, without having access to the graphical level of the Android OS. And therefore, we must look towards installing the server in the "standard" android way, so that it has access to the hardware and the ability to maintain a graphical environment.

The smart guys in the developer community came up with two solutions to this problem. The first is to use your own versions of Linux (usually the X server). After they start working in the background, you will have access to this background process through VNC. If you already have a VNC viewer on your Android device to interact with other computers remotely, just use it to access the local host remotely. This is an easy solution, however, some users report having problems 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 paid and free versions. Before installing, you need to check if the chosen option is supported, or at least works with the Linux for Android software package that you are going to install. We preferred the X-Server system, and therefore used the XServer XSDL software package ( link). This article will describe the installation process for this server, although it may differ slightly if you have another application installed or if you are using VNC.

System Selection

As in the case of X-Servers, there are several applications in the Play Store for installing distributions of the Linux system. Here, as well as with Termux, we will focus on options that do not require root access, which in turn involves a certain degree of risk. These applications provide all the functionality that most users need while keeping your data safe. Below are examples of such apps in 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 lists of large distributions and can include Ubuntu/Debian, Fedora/CentOS, openSUSE and even Kali. There you can also choose low-cost desktop options: Xfce4, MATE, LXQtand LXDE. It requires Termux to be installed, and the Android operating system must be from 5.0 and higher.

β€” Andronix very similar to AnLinux. Possibly better designed than the previous application, but supports fewer distributions.

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

The authors of this article will be using the UserLAnd app to install a Linux desktop on Android, and there are several reasons for this. First, the application is open source (although AnLinux has it too). Secondly, it offers a good set of distributions (although it does not include Fedora or CentOS), and it can also be used to install distributions with minimal 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'll find out exactly what this means for us later. Now let's install UserLAnd on your device.

Application UserLand

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

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. Rounding it out is the Firefox app, a couple of games, and a few office utilities: GIMP, Inkscape, and LibreOffice. This tab is called Applications. It is designed to install applications.

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

β€œFilesystems” is the last tab which shows already completed installations. It is worth noting that after you delete any element 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, so we'll start by installing the application in the UserLAnd system environment.
Install Linux desktop on Android

Before you install the distribution kit on your smartphone, you need to give UserLAnd access to the storage.

Distributions in UserLAnd

Select one of the distributions located on the Apps screen to install on your device. We will use Ubuntu as an example. Clicking on the icon brings up a dialog asking for a username, password, and VNC password. Then select the method by which you will access the distribution. The download will begin, during which the base image of the selected distribution will be used. The file will be unpacked in the UserLAnd directory.

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

uname –a

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

sudo apt install lxde

The last step is to make sure your new desktop environment is ready to run. To do this, you need to edit the file .xinitrcfile, which currently has only one line /usr/bin/twm. It needs to be changed to /usr/bin/startlxde. Now exit the XSDL session (make sure to click the STOP button in the notification area), hold down 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. In it, you can do the same as on a regular desktop. It just might be a little smaller and a little slower: you have to wait longer to press a button on a device than if you did it with a keyboard and mouse. Let's see how specifically we can improve the Linux system environment on a smartphone.

Quick Guide to UserLAnd

A close examination of the contents of the desktop reveals an exact recreation of the desktop version. If you are using UserLAnd on a device with a keyboard and mouse (whether connected via Bluetooth or otherwise), it will be easy for you to adjust to using the Linux system environment in this format. Except for a slight lag, which comes from the fact that the X-Windows cursor is synchronized with the Android device cursor, everything works smoothly.

Perhaps the first thing you want to do is adjust the default font system, because the desktop font size is too big for the phone screen. Go to the main menu, then select "Settings" β†’ "Customize appearance and widgets" β†’ "Widget". Here you can change the default font size to something more appropriate for your phone.

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

sudo apt install emacs

Install Linux desktop on Android

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

Install Linux desktop on Android

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

You will probably also need alternative connection methods for your distribution. Just because you initially set XSDL doesn't mean it has to be the same all the time. You can create another account on the Session tab and select a different server. Just be sure to point it to the same file system. UserLAnd will attempt to direct you to the correct application to establish a new connection type: either XSDL, ConnectBot for SSH, or bVNC.

However, the persistence with which the app automatically directs you to the Play Store when you try to reconnect can be annoying. To stop this, it is enough to change the server by installing a special application. To install SSH, select the old trusted VX ConnectBot. Just log in to port 2022 on the workstation with your username and password. To connect to a VNC server, all you need to do is install the commercial, but in many ways advanced Jump Desktop application, and dial the address 127.0.0.1:5951.

We hope you remember the VNC password you 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 running session (with connection type SSH, of course) using a Linux terminal, such as Konsole, or connect to a VNC session using KRDC. Just replace the local addresses on your computer screen with your Android's IP addresses.

Combined with a couple of portable applications, this setup will give you a handy portable Linux system that you can connect to using any computer you have available at the moment.

Source: habr.com

Add a comment