A simple Termux tutorial for beginners

๐Ÿ‡น๐Ÿ‡ผ ไธญๆ–‡็‰ˆ

Termux is an open-source terminal emulator for Android devices. It has its own package manager so you can download and run commandline tools in Termux.

And Termux is also a good tool for learning shell scripting and programming (Python, C/C++, Java, NodeJS…) on your Android phone.

Termux is also capable of running Linux containers (Ubuntu, Fedora, Arch..) on your phone without root permissions.

Please note:

  • Termux CANNOT ROOT YOUR PHONE! If you want to modify system settings, you must root your phone first (e.g. unlocking bootloader and flashing Magisk).
  • Do not install suspicious packages or running random scripts on the Internet! It may be harmful to your device.
  • Termux is not for hacking.

In this article I will tell you how to install and setupt Termux properly.

1. Download Termux APK

Please download Termux apk from F-Droid, the open-source app store.

The maintainers of Termux stated that Termux on Google Play is no longer maintained. It may contains lots of bugs.

2. Things to do after installing Termux

  1. Launch Termux APP, the terminal will pop out.

  2. Scroll down the notification bar you shall see two options. Exit will kill the app and Acquire wakelock will keep Termux running in the background.

  3. Go back to Termux. Swipe from left edge. Pressing Keyboard will open phone keyboard and New session will open a new terminal.

  4. OK. Now it is time to type some commands. First let’s upgrade the packages, type this and press enter (you could long press in Termux to paste commands)

1
pkg update
  1. It should start downloading and installing updates. During the installation, it may ask “Do you want to install XX package?” then please type y to continue.

  2. If the downloading speed is too slow, consider changing Termux mirrors. Type this:

1
termux-change-repo
  1. A dialogue wil pop up. Now press up arrows on the screen to move the selection. Move to Single mirror and press enter.

  2. Select any mirrors at you wish. For example Mirrors in Asia.

  3. Termux wil try to refresh packages list. Type y to continue.

  4. Finally, give Termux permissions to access your files in internal storage (DCIM, Downloads, Documents…).

1
termux-setup-storage
  1. Last but not least, Termux may crash when running in the background on Android 12+ devices. If so, learn how to disable Phantom Processes Killing.

3. How to install packages in Termux

To install packages (software) in Termux, type pkg install <package-name>. Note it does not require sudo to install packages.

For example, to install Python in Termux, type:

1
pkg install python3

To remove Python pakcage:

1
pkg remove python3

To upgrade all packages:

1
2
pkg update
pkg upgrade

To search specific package on Termux repository:

1
pkg search <pkg-name>

4. Commands of Termux

The default shell of Termux is Bash.

Commands such as ls, cd, mv, cp, touch are available in Termux.

You could learn usages of Bash commands on The Bash Guide.

5. What can you do with Termux

There are many things you could do in Termux. Belows are some examples. Texts with gray background are packages which could be installed in Termux.

5.1. Programming

Install command-line text editors vim or nano for writing codes in Termux. (Learn how to use VIM). It is also possible to install Visual Studio Code in Termux, you need to install Proot Debian in Termux

  • Install clang to compile C/C++ programs (GCC is not available currently)
  • openjdk-17 for running Java programs.
  • python3 for running Python programs. python-pip for installing Python packages. Anaconda is also installable on Termux.
  • nodejs for running NodeJs programs.
  • mono for .Net frameworks.

go-lang and rust are also available in Termux.

Install git for managing projects on Github or Gitlab.

5.2. Multimedia processing

ffmpeg for editing and converting videos.

imagemagick for batch processing images.

Install youtube-dl with pip to download Youtube videos.

If you need more advanced image/video editing software, setting up Proot Debian then install Kdenlive, GIMP, Blender.

5.3. Gaming

You could play PC games, such as Minecraft Java Edition and Undertale, in Termux. Though the performance is not that good.

Learn how to install virglrenderer in Termux.

5.4. Running Linux containers and Windows VM

proot-distro allows you to install Linux containers in Termux , for example Debian and Arch Linux. The benefit is that you could find more packages than Termux in proot Linux distro.

You could use qemu to run Windows virtual machine in Termux. However, the performance is very bad, even on flagship phone it takes 5 minutes to boot a Windows 7 VM.

It is possilbe to run docker in Termux with custom Android kernel (root required).

5.5. Remote access

Install openssh for running SSH services.

6. How to access Termux files

To access Termux direcotry, install Material Files.

Swipe from left edge, click Add location then select Android/data, choose Termux’s directory.

Then you could copy and move files from Termux’s $HOME directory.

7. Where to ask for help

Please read Termux Wiki before asking questions.

r/Termux on Reddit is a good place for discussing Termux topics. DO NOT ASK HACKING QUESTIONS OR YOU WILL GET BANNED.

Report bugs on Termux Github.

If this article is helpful to you please consider supporting me.