Skip to main content

A simple Termux tutorial for beginners

Categories   Smartphone Termux Tutorial
Tags   Termux
Table of Contents

🇹🇼 中文版

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.

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

It 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).
  • Double-check before installing 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
#

Do not install Termux from Google Play store. The maintainers of Termux stated that Termux on Google Play is no longer maintained. It is outdated and contains lots of bugs.

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

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)

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:

termux-change-repo
  1. A dialogue will 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…).

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.

Type pkg help for usages.

For example, to install Python in Termux, type:

pkg install python3

To remove Python pakcage:

pkg remove python3

To upgrade all packages:

pkg update
pkg upgrade

To search specific package on Termux repository:

pkg search <pkg-name>

4. How do you learn Termux?
#

Well, there are many things to learn in Termux, if you really want to master it.

For example, the default shell of Termux is Bash. Commands such as ls, cd, mv, cp, touch are available in Termux. You could learn all usages of Bash commands on The Bash Guide.

Apart from bash commands, you could also learn how to use Termux API, Termux X11, Termux Python bindings…

That’s too much, right? Gee! I don’t want to learn command lines on my tiny smartphone!

My suggestion: Start from the basics. You should learn how to use Linux first. Because Termux is different from “normal” GNU/Linux distributions on PC (see wiki), it’s a relatively limited environment in comparison with GNU/Linux distributions. There are many limitations. I would suggest you to install a real Linux distribution, such as Ubuntu, on your PC (through Virtualbox or WSL) to learn the basics of command lines. You could search “Ubuntu course for beginners” to learn how to use Linux.

After you know how command line works, you could apply your knowledge to Termux, so you would have a clear picture of how everything works behind the scenes.

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 yt-dlp 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 to run SSH daemon on your PC, or login to your PC from phone using ssh commands.

5.6. Terminal for Android shell
#

Termux can act as a terminal for the Android shell.

If your phone is rooted, you can use Termux with Busybox to run commands on Android, such as modifying Magisk module files, or installing chroot Linux distribution.

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.

Related

How to install proot Debian in Termux on Android phone (XFCE desktop + Audio + One-click starter)
Categories   Smartphone Termux Tutorial
Tags   Termux Debian
Installing Anaconda on Android (aarch64) devices
Categories   Smartphone Termux Tutorial
Tags   Termux
How to run Stable Diffusion on Termux on Android phone
Categories   Smartphone Termux Tutorial
Tags   Stable Diffusion AI Android Termux

Leave a comment

Choose the comment system you like. Giscus for codes, Disqus for anonymous comments.

Please login to your Github account to leave a comment. You can post codes here for discussion. For images, please upload to Imgur and copy links. Your comments would be visible to everyone on Github Discussions.

This comment system is provided by Disqus, you may see forcing Disqus ADs on this page. Sometimes your comment may need to be reviewed, resulting in delayed display. Thank you for your understanding.