Skip to main content

Command Palette

Search for a command to run...

Termux

Published
•4 min read•View as Markdown
Termux

Termux is an Android terminal emulator and Linux environment app that allows users to run a Linux shell on their Android devices. It provides a platform to install and use various command-line tools and packages, making it a powerful tool for developers, hackers, and enthusiasts to perform tasks ranging from programming to system administration directly on their mobile devices.

Installing Termux

Termux is an open-source software project by a group of dedicated developers who thought of making it possible to give the mobile phone similar capability as the laptop or desktop computer for coding. With Termux, you can learn and code in most programming languages such as C/C++, Objective-C/C++, Java, Python, HTML/CSS, JavaScript etc. right on your phone.

With the F-Droid application still open, follow these steps to install Termux.

  1. Tap on the green search button at the bottom right corner of the screen.

  2. Type termux in the search bar and tap on the search arrow button.

  3. Tap on Termux Terminal Emulator with packages from the list of applications.

  4. Tap on the install button and wait for the installation to complete.

Setting Up Termux

At this stage, we have successfully installed Termux. We will now proceed to set it up. We will first update the Termux machine, and install Python3, Clang, a code editor and any additional language of our choice. Tap on the Termux application icon to start it.

  • Type the following command to update the Termux machine

    pkg update && pkg upgrade

The screen will be flooded with several texts as Termux checks for updates. When prompted with the question, “Do you want to continue? Y/n,” type y and press the enter key. Wait for the update to complete.

  • Grant Termux access to the phone’s storage. This will enable Termux to save any file you create. Type this command and press the enter key.

    termux-setup-storage

  • Next, type the following and press the enter key

    pwd

This command means print the working directory. It instructs Termux to print the path to its home directory. You will see something similar to /data/data/com.termux/files/home

  • Type this and press the enter key.

    ls

This command instructs Termux to display all the files and directories (folders) inside the current directory. The directories are colored blue or similar depending on your system. You will see storage as one of them. This is the main storage directory for the phone.

  • Type the following command and press the enter key.

    cd storage

The cd stands for change directory. It instructs Termux to move into a specified directory, storage in our case. After pressing the enter key, you will see the path change from ~ $ to ~/storage $. We are now in the storage directory. You can check what files and directories are in the storage folder by using the ls command as we did earlier.

Note

You can get rid of the text on the screen by typing clear and pressing the enter key. This command instructs Termux to clear the screen. It does not affect any file or directory on your device.

  • We can now install the packages we will need to start coding. Let's start with the following.

    pkg install git curl wget

These packages will help you to clone and download files from the internet which can enhance your programming experience.

  • The next package to install is the following.

    pkg install vim

The Vim package is an editor with multiple capabilities. It can be used to code and type any document. When prompted to continue, type y and press the enter key. Check out this tutorial for how to use the Vim editor.

  • The next package to install is Python.

    pkg install python3

Python is a high-level programming language used to develop a plethora of programs including web applications, desktop applications, and games, used in machine learning and artificial intelligence among others. It is used by top companies around the world. It is one of the most in-demand programming languages of the 21st century and it is surprisingly easy to learn.

  • The next package to install is apache2

    pkg install apache2

Apache2 is a free and open-source application that enables you to host your website locally on your device for testing.

  • Finally, those who would like to program in C/C++, Objective-C/Objective-C++, Java, Fortran, Ada, Go, D, and Modula-2 can proceed to install the Clang package.

    pkg install clang

The Clang package comes with a compiler to help you debug your code.