Any Android phone or tablet is a device that runs Linux. Yes, a very modified OS, but the core of Android is the Linux kernel. But, unfortunately, for most phones the option "demolish Android and install the distribution kit to your liking" is not available.
Therefore, if you want Linux on your phone, you have to buy specialized gadgets like PinePhone, which we already wrote about in one of the articles. But there is another way to get a Linux environment on almost any smartphone, and without root access. An installer called AnLinux will help you with this.
What is AnLinux?
This is specialized software that allows you to use Linux on your phone by mounting an image containing the root file system of any distribution, including Ubuntu, Kali, Fedora, CentOS, OpenSuse, Arch, Alpine and many others. The installer uses PRoot to emulate root access.
PRoot intercepts all calls made by the user that normally require root access and makes them work normally. PRoot uses the ptrace system call to debug software to help achieve its goal. With PRoot, all this can be done as with chroot, but without root rights. In addition, PRoot provides fake access to the user for the pseudo-file system.
AnLinux is a small program. But this is enough, because its only purpose is to install system images and run scripts that raise the user environment. When everything is done, the user gets a Linux-PC instead of a smartphone, and Android continues to run in the background. We connect to the device using a VNC viewer or terminal, and you can work.
Of course, this is not an ideal option to "get" Linux on a smartphone, but it is quite working.
Where to begin?
The main thing is an Android smartphone with an OS version not lower than Lollipop. In addition, a 32-bit or 64-bit ARM or x86 device will do. It also requires a substantial amount of free file space. To do this, you can use a memory card or just a device with a large amount of internal memory.
In addition, you will need:
- AnLinux (here is the Google Play link ).
- Termux (will need Google Play again ).
- VNC Client ( VNC Viewer is a good option).
- Bluetooth keyboard (optional).
- Bluetooth mouse (optional)
- HDMI cable for mobile phone (optional).
Termux and VNC are needed to gain access to your "Linux computer". The last three elements are required only to ensure comfortable work with the phone and the installer. An HDMI cable is needed only if it is more convenient for the user to work with a large screen, and not to peer at the phone display.
Well, let's get started
Once Termux is installed, we get a full-fledged console. Yes, there is no root (if the phone is not rooted), but that's okay. The next step is to install the image for the Linux distribution.
Now you need to open AnLinux and then select Dashboard from the menu. There are three buttons in total, but you can choose only one, the first. After that, the distribution selection menu appears. You can choose not even one, but several, but in this case, you will need a large amount of free file space.
After choosing a distribution, two other buttons are activated. The second allows you to load the commands necessary to download and install Linux to the clipboard. Usually these are pkg, wget commands and a script to execute them.
The third button launches Termux, so commands can be inserted into the console. Once everything is done, a script is launched to load the distribution environment. To call the distribution kit, you need to run the script each time, but we install it only once.
And what about the graphical shell?
If you need it, you just need to select a menu for the desktop environment and use more buttons - not three, but more will appear. In addition to the distribution itself, you also need to choose a shell, for example, Xfce4, Mate, LXQt or LXDE. All in all, nothing complicated.
Then, in addition to the script that starts the distribution, you will need another one - it activates the VNC server. In general, the whole process is simple and straightforward, it is unlikely to cause difficulties.
After starting the VNC server, we connect from the client side using the viewer. You need to know the port and localhost. All this is reported by the script. If everything is done correctly, then the user gains access to his virtual Linux system. The performance of modern phones is excellent, so there won't be any particular problems. Of course, it is unlikely that a smartphone will be able to completely replace the desktop, but, in general, it all works.
This method can be useful if you suddenly need to urgently connect to the server, and you are in the car, without a laptop (of course, in this case, all the operations described above with AnLinux should already be performed). A Linux virtual machine allows you to connect to your work or home server. And if for some reason there is a display and a wireless keyboard in the car, then in a matter of seconds an office can be organized in the cabin.