Skip to main content

A simple Termux tutorial for beginners

·
Categories Smartphones Termux Tutorials
Tags Termux Linux Android
Table of Contents

How to use Termux App?

Android is a Linux-based system, but it lacks a terminal. Termux, an open-source terminal emulator, fills this gap, allowing it to be used without root access and even has its own package manager.

Termux is a terminal emulator app that ports many commonly used Linux command-line programs to Android. Why type commands on your phone? Sometimes your phone doesn’t have a corresponding app for doing some tasks, but you can still achieve your goals using command-line software.

For example, Termux can be used for SSH connections, video transcoding, server setup, programming learning, and more. Furthermore, Termux provides a tool called proot-distro, which can create Linux container environments and run more Linux desktop programs.

Example usage: Running PC version of Firefox and XFCE Desktop on Android phone using Termux app.

Example usage: Coding Python with Vim on Android phone using Termux app.

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
#

Termux requires an Android device running Android 7 or later.

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 or Github. For most devices, choose the arm64-v8a variant.

2. Things to do after installing Termux
#

2.1. Interface overview
#

  1. After opening Termux, you’ll see the terminal interface. Tap the input box, and your phone’s keyboard will automatically open. The Termux screen also displays keyboard shortcuts like Ctrl and Esc, which you’ll frequently use when operating the terminal.

  2. Pull down from the notification bar and press Exit to immediately terminate Termux; Acquire Wakelock keeps it running in the background.

  3. Swipe in from the left side of the screen and press New Session to open multiple Termux terminals (working sessions); press Keyboard to wake up the phone’s keyboard.

  4. How to input Chinese in Termux: Swipe the bottom toolbar to the left to reveal the input box.

  5. If you find the Termux text too small, use two fingers to zoom in and out of the terminal screen.

2.2. Update packages
#

Linux systems typically install software from software repositories; those familiar with Ubuntu should understand this.

Termux packages are primarily in .deb format. The pkg command is essentially an APT wrapper, but you cannot directly install .deb packages from Ubuntu/Debian systems. Termux repositories contain modified versions specifically for mobile devices.

  1. After installation, software packages need to be updated to function correctly. Use this command to update all Termux packages (long press in a blank area of ​​Termux to paste the copied command):
pkg update
  1. Termux will automatically download, update, and install packages. During the update, it may ask if you want to upgrade packages; always type y and press Enter.

  2. Commonly used commands for installing software are as follows:

# Install a package
pkg install <package name>

# Uninstall a package
pkg uninstall <package name>

# Search for packages
pkg search <package name>

# Update all packages
pkg update && pkg upgrade

# Automatically remove unused packages
pkg autoclean
  1. The Termux pkg command is actually a wrapper of the apt command, so you can also use apt update to update packages. However, you cannot directly use Ubuntu’s package repositories, nor can you just use dpkg to install any .deb file.

2.3. Switch mirrors
#

Termux has mirror sites in various countries to speed up package downloads. This step is optional; if not set, Termux will try all mirrors globally before downloading each package.

  1. Enter the following command:
termux-change-repo
  1. Use the up and down arrow keys displayed in the Termux terminal to switch to Single mirror, then press Enter on your phone’s keypad.

  2. Select Mirrors in Asia and press Enter. Users in China can select Mirrors in China.

  3. Termux will refresh the package list. Enter y to continue using it.

2.4. Fix signal 9 error
#

Preventing Termux from being killed by the system.

If your device is running Android 12 or later and you plan to use it to run large programs such as Linux desktop applications, please be sure to disable Phantom Process Killing to prevent Termux from being killed by the system in the background.

3. 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.

3.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.

3.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.

3.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.

3.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).

3.5. Remote access
#

Install openssh to run SSH daemon on your PC, or login to your PC from phone using ssh commands.

3.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, orinstalling chroot Linux distribution.

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. How to access Termux files
#

How to grant Termux access to Android’s internal storage?

“Internal storage” refers to the location of directories such as DCIM, Download, Document, and Android. You can view this using a file manager app.

  1. Enter the following command to grant Termux access to your phone’s internal storage:
termux-setup-storage
  1. After granting Termux access, it will be mounted to the storage/shared directory in the Termux home directory. Confirm this by entering the ls command:

  2. To switch to the internal storage/Download directory, simply enter:

cd storage/shared/Download
  1. Then use the ls command to view all files in that directory.

For detailed information on Termux file management, please refer to: A Brief Introduction to Termux File Management

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


Thank you for reading. Public comments are not available on this website. I write to explore ideas honestly, not to chase social engagement or traffic. I would be glad to hear your thoughts after reading the article with care. If you found any errors, technical issues, or would like to share feedback, feel free to contact me via the email listed on the About page.