How to install Linux and VS Code on Android

How to install Linux and VS Code on Android

In this post, we'll install Linux on an Android device and we'll see how you can install VS Code on your Android phone. To achieve this, we'll use one of the most popular Android terminal applications, Termux.

Step 1: Install Termux

We'll start by installing Termux. We will download Termux from F-droid by clicking on this link

Note: You don't have to download F-droid, scroll down and click on download APK as shown in the image below.

The official release available on the Play Store doesn't seem to be getting any updates for some reason. That's why Termux from the Play Store will not work.

Here is what the official GitHub repository of Termux has to say,

Here is what the official GitHub repository of Termux has to say,

“Termux and its plugins are no longer updated on Google Play Store due to Android 10 issues and have been deprecated. The last version released for Android >= 7 was v0.101. It is highly recommended to not install Termux apps from Play Store anymore.

…...

You are encouraged to move to F-Droid or Github builds as soon as possible.”

Now, open the downloaded APK by clicking “Open”

Click on “Install” and if prompted go to settings and enable permission for installation from unknown sources.

Open the Termux app and you’ll see a screen like below:

Step 2: Install Linux

In this post, we will choose Ubuntu as our Linux distro. You can choose your preferred Linux distribution.

First, Enter the following command and hit enter:

pkg update

When prompted press ‘Y’ and hit enter. Remember, whenever you’re prompted for it, press ‘Y’ and hit enter.

Now, let's upgrade the packages in Termux using the following command:

pkg upgrade

Now, let’s install proot-distro using the following command:

pkg install proot-distro

You can list all the available distros that can be installed with proot-distro using the following command:

proot-distro list

You’ll see a screen like this:

Run the following command and Ubuntu will start to install on your Android phone (you can change ubuntu with your preferred distro’s name in the command):

proot-distro install ubuntu

This will start installing Ubuntu and you’ll be able to see a screen like this:

To log in to Ubuntu run the following command:

proot-distro login ubuntu

You will see a screen as below:

Step 3: Downloading code-server

Run the following commands while you are still on Ubuntu

apt update
apt upgrade

Press ‘Y’ and hit enter whenever prompted

Run the following command to install wget

apt install wget

Again press ‘Y’ and hit enter whenever prompted to confirm the installation. Now, you’ve successfully installed wget

We’ll now download the latest release of code-server from Github using the following command:

wget <https://github.com/coder/code-server/releases/download/v4.16.1/code-server-4.16.1-linux-arm64.tar.gz>

Note: visit this link to check for the latest version of code-server and replace the version in the above command with the latest version.

You’ll see something like this on your screen:

Now, extract the tar file using the following command (change the version as needed):

tar -xvf ./code-server-4.16.1-linux-arm64.tar.gz

The tar file will start extracting

Use the following commands to go to the /bin directory of your code-server installation on Ubuntu (which is running on your phone)

cd code-server-4.16.1-linux-arm64
cd bin

Step 4: Set up a password and start using VS Code

Set up a password for your VS Code instance using the following command:

export PASSWORD="password"

Note: For demonstration purposes, I’m using a very weak password. Consider using a strong password for your more serious projects.

Run the following command to launch the code-server:

./code-server

Copy the link from where it says, “HTTP server listening on ”

Now, go to your favorite browser on your Android mobile and go to localhost:8080

A screen like this will appear:

Enter the password you set earlier and press “SUBMIT”

Once you do so, you’ll see a welcome screen like this:

Now, you can start coding in VS Code on your Android Device

Hope that worked for your phone. Please share your experience, ask questions, or suggest improvements in the comments section. Happy Coding!