Android itself is a great operating system for smartphones. It gives you flexible controls and extensive customization options by installing 3rd party applications (APKs) from Play Store. While that’s incredibly easy but it comes with a privacy compromise.

Termux Terminal Emulator running in Android Custom ROM, LineageOS 17.1

Almost every Android app these days asks for Phone’s Storage, Location and Camera access permissions which is questionable act and privacy nightmare.

Advertisement

This is where Ubuntu 20.04.1 (Command Line Interface) comes in. Ubuntu is a widely used distribution flavor of GNU Linux that is easy to use and compatible with many devices. By installing Ubuntu Linux on our Android phones we can simplify, automate and schedule many daily tasks and preserve the phone battery life at same time.

However, the requirement is that we must understand basic Linux (Bash) commands first, but don’t worry about that now.

Benefits of Installing Ubuntu on your Android phone:

Here’s a short list of things that you can do after installing Ubuntu 20.04.1 through Termux (Terminal Emulator) for Android. The great things is that Rooting or Unlocking Bootloader or installing Recovery (e.g. TWRP) is not required.

• Ability to run Python v3.5.8+ programs and scripts (.py)

• Run crontab (crond) to automatically run Bash scripts/tasks at specified times.

• Make Bootable Windows 10 USBs for your Desktop PC

• Use aria2c download manager to download magnet links, get files multi-threaded/connections.

• Host Websites from your Android phone by installing Nginx, MYSQL and PHP

• Make use of Termux-url-opener and Termux-setup-storage to automate the downloading of files using “Share” dialog box on Android OS.

• Install Qbittorrent-nox (WebUI), Transmission WebUI to remotely download legal torrents

• Control your Phone from other devices on your LAN using SSH (openssh-server)

• You can automate your phone to capture a Picture at specific intervals using Termux API.

How to Install Ubuntu 20.04.1 (CLI) on Android 7/8/9/10

It is recommended that you use at least Android 6+ for this guide so you don’t get compatibility issues.

Download Termux app from Play Store. It is free and allows you to run Bash terminal where you can run Linux/Unix commands and execute bash scripts.

Play Store page of Termux Emulator for Android

Once the installation is done, start Termux from your Launcher or Home Screen. You will be greeted with Black screen with some text, and $ sign. Don’t panic, it’s totally normal. Just Tap on $ sign and keyboard will pop-up. This is where we will type and enter commands.

Termux Launcher Icon on Android Home Screen on Android 10

The black screen, you are seeing is called Command Line Interface (CLI) or Terminal.

Now type the commands given below, after entering one command, wait for the process to complete and then proceed with the next. Some commands will output what is happening (Logs) some will not. Don’t worry when that happens. Don’t copy the $ sign, it is for reference only. 

Typing command into termux shell inside Android OS

Note: Package installation and scripts usually ask for User confirmation with Yes or No. Typing Y and hitting Enter will give the terminal to go ahead with command.

$ apt update && apt upgrade

This command will update the software package list and upgrade the software afterwards. The && sign we placed in between tells terminal to perform one task and then do the other.

$ apt install wget -y

Now that we have upgraded our Terminal packages. It is time to install wget. It is a file retriever like IDM but for command line, it can download content from many protocols.

$ apt install proot -y

proot (chroot) allows us to run Ubuntu under user specific directory without permission issues. It is basically fake root, you can do anything except making changes to internal hardware of phone. For example; Android Debug Bridge (ADB) shell is not supported as it requires root.

$ apt install git -y

Git will help us clone the open-source script from Github. The script will be used for installing Ubuntu using proot on Termux.

$ cd ~ && git clone https://github.com/MFDGaming/ubuntu-in-termux.git && cd ubuntu-in-termux

The above command will open your $HOME directory and then clone (download) the Ubuntu.sh script from git and then access the directory where it is cloned.

$ chmod +x ubuntu.sh

This command will give current user (you) permission to execute Ubunut.sh script. You can alternatively enter “bash ubuntu.sh -y” to directly run the installation script.

$ ./ubuntu.sh

This command will execute and start the downloading and installation of Ubuntu 20.04.1 Root filesystem.

Note that this operating system is minimal and does not have desktop environment (GUI), such as XFCE. The reason we have installed the Ubuntu CLI is that it is not resource hogging and perfect for running on Mobile ARM64 / aarch64 supported CPUs.

Once the installation script has completed the process, now we run finally start the Ubuntu

$ ./startubuntu.sh

After you hit enter, your the $ sign in Termux will be replaced with [email protected]:-~# indicating that you are now in Ubuntu Shell (terminal).

To exit Ubuntu and go back to Termux Terminal, type exit


Few Basic Linux Commands:

These commands are universal Linux commands, they can be entered in any GNU/Linux shell, regardless of distribution you are currently using. To utilize the Termux to its full potential, you must Google and learn Linux commands, they are really easy but dedication is required.

pwdShows present working directory

ls -a  shows the list of directories and files, including hidden files

mkdir foldernamecreates new directory in directory in pwd

rm filename.txtremoves the file in pwd

cd directoryname opens the directory

cd ~ – Takes you back to $HOME directory, it’s like the User folder in Windows.

uname -a – Shows system information, Linux OS name, Kernel, Platform and so on


What to do after installing Ubuntu in Termux (Android)

0. Important Initial Step

It is a good practice to give Termux permission to internal storage of your phone.

Termux-setup-storage

Once you enter this command, Android OS will ask for storage permissions, click “Allow“. Doing this will give Termux to access the internal storage eMMC / SD card of your Android OS. You can copy, move and share files between Termux shell and your Android storage back and forth.

1. First thing you must do is to update the repositories and upgrade the packages.

[email protected]:-~# apt update && apt upgrade

2. Install Python and PIP for downloading programs and running scripts:

[email protected]:-~# apt install python3 python-dev python3-pip

3. Install wget, curl and git for acquiring files from different sources

[email protected]:-~# apt install git curl wget

4. Install useful Python Packages using PIP

[email protected]:-~# pip install --upgrade youtube-dl gallery-dl ffmpeg

5. Install nginx (http) server for hosting websites

[email protected]:-~# apt install nginx

 

Remember! the possibilities as I mentioned are endless. The prerequisite is that you must learn basic Linux (Bash) commands to navigate between directories and give basic arguments to commands. If you would like more tutorials on Termux / Ubuntu, do let me know through comment section.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.