How to run Linux on your Android smartphone | | Resource Centre by Reliance Digital
Home > HOW-TOs > How to run Linux on your Android smartphone

How to run Linux on your Android smartphone




Share This Post

We have all heard of Linux, but did you know it’s possible to run an entire Linux distribution right on your smartphone? That’s right, you can have a desktop operating system with the interface on your smartphone, even without having to root it or remove Android. There are a ton of possibilities. You can now run full-fledged PC software on your smartphone and if you want, even connect a keyboard and mouse to your phone, and an HDMI cable from the phone to your TV or monitor too. That way, you could be carrying a desktop PC setup everywhere you go. Here’s how to go about running it.

Installing the packages needed

Note that you won’t be replacing Android on your smartphone, merely running Linux within Android using a couple of free software. All of them are available on the Play Store. The first is called Andronix, which lets you create a simple script that starts the download and automatic installation of the Linux distribution of your choice. The second piece of software is called Termux. You can also find it on the F-Droid Store. It’s a terminal emulator that lets you run Linux command line software on your smartphone. There are several uses of Termux, and we might get into those details in a separate feature article.

Choosing the distribution

The way the entire process works is that we first open Andronix. You will be shown a list of distributions to choose from. The popular ones are Ubuntu, Fedora, Manjaro, Arch and Debian. Alpine is the most compact one of the lot, but it requires a lot of tinkering to feel comfortable. If it’s your first-time using Linux, select Ubuntu. Click the Install button and you’ll be asked to choose a version. You can choose either, 18.04 or 20.04. The 18.04 released in 2018, and 20.04 arrived in 2020. Andronix will then copy the commands needed to install the distribution to the clipboard.

Starting the installation

Next, open Termux and paste the text by holding down the screen at the prompt. Use the keyboard to press Enter. The installation process involves downloading a bunch of scripts, packages and installing the operating system on your phone. Make sure you’re connected to a fast internet connection and that you have some storage space too. Depending on the platform you chose, the script may download a lot of data. You will see a lot of scrolling and text go by. You may only be prompted to confirm a few commands. Pressing the Enter key uses the default option. The installation can take a while like installing any other operating system on an actual computer.

Configuring VNC

The last step of the installation will ask you to choose a resolution for the VNC server. The VNC server is a tool that lets you remotely access the desktop. Typically, it’s used to connect to a laptop or PC from a remote location over a network. In this case, Linux runs within Termux and to access the graphical interface, you will need to a VNC client. You can install the one from RealVNC from the Play Store. There are other alternatives you can choose from too.

Connecting to your smartphone’s VNC server

Now that your Linux distribution has been installed and the VNC server is running, open the VNC Viewer on your phone. You will be asked to enter a server address. Enter localhost:1 and click on Connect. Your VNC client should connect to the Linux distribution running on your smartphone at this point.

Your Linux distribution is up and running!

You can now use the Linux distribution on your smartphone like on any other laptop or desktop. You can find the app store on the distribution, and install addition software, or even open the terminal on the Linux distribution to install more packages. You can add wallpapers, store data and do a whole bunch of things, even run software and programs that would never run natively on your Android smartphone.

The Linux distribution needs to be shut down in the same manner as any other laptop or PC. You can also force the Linux distribution to turn off by closing the termux app, although it’s not recommended.

Booting your Linux distribution

You might notice, there is no clear way to get your Linux distribution back up running again. For this, run Termux and type ls there. It lists all the files in that folder. There should one file ending with a .sh extension. Type ./start_ubuntu20.sh to run it (or the file name for your Linux distribution). This will fire up your Linux distribution again. Give it a few seconds to boot up and you should be able to login using VNC back into the Linux desktop again. If the VNC server isn’t running, you can also type vncserver on the console and press Enter.

There are also ways to get your VNC server accessible from over the network. That way, you can access your phone’s Linux distribution from a laptop or PC on your network. You could also buy an OTG adapter or use Bluetooth to connect a wireless keyboard/mouse to your phone and use it a PC connected to a TV or monitor. The possibilities are endless. It’s left to your imagination what you wish to do with this setup.

While it seems complex at first, it’s quite easy to get Linux running on your smartphone. You can also try out some of the other distributions and have them installed in no time. If you thought that was fun and interesting, keep checking out RelianceDigital.in for more such interesting How-tos and neat software to mess around with!