Skip to main content

How to install Linux on an Android phone

Why not?

Once you've selected a distro, the app will display detailed instructions broken down into four pages. On Page 1 the app runs through the basic requirements your device must meet to be able to run a Linux distro. The most important step is to make sure that you've enabled the debugging support.

To do that, head to Settings > Applications > Development and make sure the USB Debugging setting is toggled. On the seond page you get links to download the image for the selected distro.

Tapping on the Download Image button pops up a window with three additional buttons to download one of the three supported image types explained earlier – Large, Small or Core.

The page also mentions details about the offered images, such as the size of the compressed image that you'll download as well as the size the image will take on your SD card once it's been extracted.

How to install Linux on an Android phone

Make sure your Android device uses an ARM v7 CPU since most distros only support that particular ARM architecture

Tapping on the image you wish to download brings up another pop up with buttons that'll either download the image from a Sourceforge mirror or via torrent. If you choose the torrent option, the app will download a torrent file, which you'll then have to feed to a torrent client to download the actual image for your selected distro.

You can download the image on a computer and then transfer it on to the SD card on your Android device. In this case, you can safely skip the instructions on this page.

You can uncompress the downloaded file either on the computer or on the device itself. For the latter, you'll need a versatile file manager such as the paid-for Root Explorer app or the free ES File Explorer app.

While compressed files are smaller and are faster to transfer than uncompressed ones, remember that they are tightly compressed and (depending on the specs of your Android device) can take some time to deflate.

However, if you're moving the images on to your device manually, it's best to house them inside a folder. For example, if you're downloading the image for the Ubuntu distro, it's best to uncompress it inside a folder called Ubuntu on your SD card.

Then move on to Page 3, which advises you on extracting the downloaded files. The rest of the page talks about how to boot the extracted images. Once booted, you'll be dropped to a terminal window. Page 4 lists instructions on how to connect to this running Linux installation via a VNC viewer. Remember to note the password listed on this page as you'll need it to connect to the VNC server running inside your distro.

Boot the distro

You're now all set to boot the new distro. Bring up the navigation menu by tapping on the app's icon or swiping from left to right and tapping on the Launch item. This will bring up the app's launcher which is responsible for booting up the distros. Use the pull-down menu on the page to select the distro you wish to boot.

If you get an error saying that the image for the selected distro doesn't exist, it means that the app can't locate the extracted image files for the distro. This can happen if you haven't extracted the downloaded file, or if you've kept it in a non-standard location. In such a case, you'll have to point to the IMG file of the distro manually.

Tap on Settings in the top-right corner inside the Launch screen which brings up a pull-down menu. Tap on Add to open the page to add an entry for your distro. Enter the name for the distro in the space provided and tap on the box with three dots to navigate the filesystem on your Android device and point to the IMG file for the distro. Tap on Save Changes when you're done.

This custom entry from your distro will now be listed in the pull-down menu on the Launch page. When you now select the entry, the app will show you a button to start the distro.

Tap on the button to boot the distro. This will launch the terminal app and grant it super user permission. Press the Enter key in the virtual keyboard to boot the distro. Since this is the first time you've started up the distro, you'll be asked to specify a password for the default user (which in the case of the Ubuntu distro is named ubuntu).

Note that this is the password for the default user account and not the password required to log into the VNC session.

You'll then be asked if you want the distro to start the VNC server (for viewing the graphical desktop) and the SSH server (for accessing the distro remotely over a secure connection).

We suggest you start them both to reap the full benefit of running a Linux distro on your Android device. Next, you'll be asked to enter the screen resolution of the VNC session. Although you can set this to any size, for best experience you should set it to the same resolution as your device.

Remember, however, that when you bring up the virtual keyboard it will hide a part of your desktop. If you are running this on a device with a big screen you can follow the guide on the project's wiki to adjust the screen size to accommodate the soft keys.

That's all the configuration it requires. The app will then prompt you to save the settings as default. It's safe to do so to avoid answering the same questions every time you launch the distro. We'll show you how to alter these settings a little later on the tutorial. For now you should just save the settings as default and let the app boot your distro.

When it's done booting your distro, you'll see a note with the relevant settings you need to connect via VNC to this Linux distro, followed by the standard Linux root prompt. If you're proficient with the Linux command line interface, you can now use this shell to interact with the distro like any desktop distro.

For security purposes, one of the first things you should do is set a new password for the root user. Enter

passwd

in the shell and enter a new password for the root user. If you've asked LinuxOnAndroid to start the SSH server while booting your distro, you can now connect to it from any computer on the network. Enter the

ifconfig

command inside the terminal on your Android device, which will print the IP address of the device, such as 192.168.2.101. To connect to the device launch a terminal on another computer and enter

ssh ubuntu@192.168.2.101

This will prompt you for the password for the ubuntu user which is the one you set when you first booted the distro. To view the graphical desktop running on top of your Linux distro on the Android device, tap on the home button to minimise the terminal app, then tap and launch the VNC app (such as androidVNC).

The VNC app will prompt you for various settings so it can connect to the distro running on the device. Enter localhost in the field that asks you for the IP address of the VNC server and 5900 as the port. In addition to these you'll also need a password to authenticate with the VNC server.

This varies from distro to distro. For the Ubuntu images, the password is ubuntu. For Arch Linux it's archlinux, for the Debian flavours it's debian and so on. The password is listed on the distro's wiki page on the LinuxOnAndroid project's website.

Note that if you are using androidVNC, the app suggests that you change the colour format to 24-bit color (4bpp). Tap the Connect button to initiate the VNC session once you've entered all the information and hey presto! The VNC client will connect to your device and display the graphical desktop that's running inside the distro you're currently running.

Again, the app developers advise androidVNC users to change the input mode to touchpad. To do so, tap on the menu button from inside the VNC session. This will bring up a bunch of options; you need to tap on Input Mode and then select the Touchpad radio button from the list of supported input modes.

You can now interact with and operate the desktop just like you would on a PC. On the androidVNC app, a single tap equates to a left-click. Tap twice to simulate a right-click. If you tap and hold, the app will display three buttons – two to zoom in and out, and one to display the virtual keyboard.

You can also use the package manager to install new apps. Remember, however, that the distro will only be able to install apps that have been ported for the ARM architecture, which is true for almost every popular app.

When you've finished, close the VNC session by logging out of the desktop. Now pull down the app drawer and tap on the terminal session that's been running in the background.

Type exit to shut down the Linux distro. When the distro shuts down you'll have to type the exit command a couple more times to exit and close the terminal session.