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.
Almost every Android app these days asks for Phone’s Storage, Location and Camera access permissions which is questionable act and privacy nightmare.
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.
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.
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.
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 root@localhost:-~# 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.
pwd – Shows present working directory
ls -a shows the list of directories and files, including hidden files
mkdir foldername – creates new directory in directory in pwd
rm filename.txt – removes 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.
root@localhost:-~# apt update && apt upgrade
2. Install Python and PIP for downloading programs and running scripts:
root@localhost:-~# apt install python3 python-dev python3-pip
3. Install wget, curl and git for acquiring files from different sources
root@localhost:-~# apt install git curl wget
4. Install useful Python Packages using PIP
root@localhost:-~# pip install --upgrade youtube-dl gallery-dl ffmpeg
5. Install nginx (http) server for hosting websites
root@localhost:-~# 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.
Tried to clone linux from the github address you specified but was met with a request for a user and password. I do not know what to enter for those credentials so I was unable to install (clone) ubuntu. I sthere a work-around for this?
Would like more tutorials. Newbie. I have installed ubuntu multiple times on termux but can not get a desktop to work. Tried gnome and xfce4 still having problems. removed and purged ubuntu and tried to start over multiple times but still having problems. Everyone tells you how to install it but need step by step instructions on what to do with it once installed. I used Anlinix to install it. Got proot set up. But what now, my understanding is it comes with gnome desktop. Even tried installing gnome3 desktop.
@Janie.
Thanks for commenting.
I would not really recommend running Desktop environment on Termux for many reasons. Termux does not have proper support for hardware acceleration, even if you manage to run the xfce4, it will be laggy and unoptimized.
Currently, I have Termux setup on my phone, I’m using it mainly for YouTube-DL, Gallery-Dl and Streamlink to easily download content on my phone using Termux API (termux-url-opener).
So if I want any video or download stream from a web page, I just click “Share” button on Android Chrome and select Termux from Share menu and then it asks me what kind of media I want to save to my phone.
An example repository on GitHub:
https://github.com/Md-Sarfaraz/Termux-For-Youtube
I will post a tutorial about it some day.
@Justin Weber how can I make it so I can oven this in VNC Viewer using a VNC Server?
root@localhost:-~# pip install –upgrade youtube-dl gallery-dl ffmpeg
change is to pip3 pip don’t work
to work is
pip3 install –upgrade youtube-dl gallery-dl ffmpeg
pip3 install –upgrade youtube-dl gallery-dl ffmpeg
@Justin Weber I’m not able to run Ubuntu on my Android 10 device. I’ve already watched one YouTuber’s video and using his and yours steps, I successfully downloaded and installed Ubuntu 20.04.1 using Termux and Andronix. I’m a second year Information Technology engineering student from Mumbai and I need to submit my Linux experiments to my college digitally. My desktop and laptop are in my home in mumbai. I came to my hometown Calcutta alongwith my parents for some family work. But I haven’t carried my laptop with me to avoid the risk of my laptop being stolen. Please help me. I’ve to perform it on my phone only.
@Utkarsh Shah,
If you could share the error you are facing that would be helpful.
Thank you so much dear! My college teacher of Operating System subject, told me that she wanted us to not only download and install the Ubuntu, but also check whether the computer will boot from the USB.
Make BIOS Changes.
Try Ubuntu before install it.
Create Bootable USB.
Create a username, password, and computer name.
I’d messaged her and she told me it’s absolutely okay as I’m away from Mumbai in my hometown Kolkata and didn’t carried my laptop with me to avoid the risk of it getting stolen. She told me to take the experiment from your friends and upload it as it is. Just I’ve to do the writing part.
BTW, I’m not able to browse the internet on Firefox browser on Ubuntu in my phone. It’s showing “Gah. Your tab just crashed.” Please help me out with this issue.
This guide is preety good. What I like these programs are nginx-light, qbittorrent-nox, and openssh-server. I’ve tried qbittorrent-nox (running my Debian Unstable minimal on Termux 0.180.0 with Proot-distro) and I was able to download files on my mobile device as a server. On top of that, it works perfectly to store files by accessing /sdcard/ or /storage/emulated/0/ (requires storage permission) for qbittorrent-nox which Proot-distro has. Other programs I mentioned never tried it, so I need more research to learn some things. Once again, this is amazing to try out much using termux just like a server on a desktop to a mobile platform.
@Kamisato Ayaka
Termux out of the box supports many programs. Ubuntu is for extras binaries/programs that cannot be installed on Linux which comes with termux.
It is truly a brilliant shell environment, however ports 1-1000 are restricted, nginx webserver can work, but on non-standard ports.
I have more guides in mind regarding termux, and it’s termux-url-opener feature which I will write later on.
Thanks for your input.
I need more tutorial on how to hack a website using ubuntu-in-termux