What is Termux & How to use the Linux Command on Android with Termux?

Brief: Today you will learn what Termux is and its features and limitations. And how to install, uninstall and manage your packages in Termux. Then learn how to enable storage access on Termux and Enable Other Repositories on Termux.

Android system is capable of many things, but at its core, it is just a UNIX-based operating system. By default, many things can be done on the Android system. However, more features can be added by rooting the device.

Rooting is not the recommended method and might break your Android system and remove the warranty. Although there are still many rich, full-featured apps available for Android devices that can run without root. One of them is Termux.

What is Termux?

Termux is an open-source Android terminal emulator that takes advantage of Android’s hidden Linux infrastructure without rooting.

It can be installed on any Android device. Initially, a minimal version will be used, but additional packages are available using the APT or PKG command.

You can easily install and set up SSH or VNC and operate it remotely using the command-line or GUI method. Python developers can install Python on it and start creating Python scripts on their Android device.

Penetration testing can be performed on your Android system using tools like Metasploit, Routersploit, Phonesploit, Hydra, Nmap, etc.

Termux Features

Below are the known features available in Termux.

  • Secure: Access remote servers using the ssh client from OpenSSH. Termux combines standard packages with accurate terminal emulation in a beautiful open-source solution.
  • Feature-packed: Take your pick between Bash, fish, or Zsh, and nano, Emacs, or Vim. Grep through your SMS inbox. Access API endpoints with curl and use Rsync to store backups of your contact list on a remote server.
  • Customizable: Install what you want through the APT package management system, which is known for Debian and Ubuntu GNU/Linux.
  • Explorable: Have you ever sat on a bus and wondered exactly which arguments the tar accepts? Packages available in Termux are the same as those on Mac and Linux – install man pages on your phone and read them in one session while experimenting with them in another.
  • With batteries included: Can you imagine a more powerful yet elegant pocket calculator than a readline-powered Python console? Up-to-date versions of Perl, Python, Ruby, and Node.js is available.
  • Ready to scale up: Connect a Bluetooth keyboard and hook up your device to an external display if you need to – Termux supports keyboard shortcuts and has full mouse support.
  • Tinkerable: Develop by compiling Go, Rust, Swift, or C files with Clang and build your own projects with CMake and pkg-config. Both lldb/GDB and strace are available if you get stuck and need to debug.

Termux Limitations

Termux does not directly support the use of packages from Debian, Ubuntu, or other Linux distribution repositories. All packages are ported to Termux first. For this reason, do not attempt to put the desktop repositories into your Termux source.list or install .deb files from the Termux terminal.

Additional restrictions:

  • You can only have one architecture, 32-bit or 64-bit, installed at the same time.
  • Apt usage under root is restricted to prevent messing up ownership and SELinux labels on the Android /data partition.
  • Downgrading is not supported. In order to reclaim disk space, Termux does not keep a history of package versions.

How to Install Termux on Android

You can download and install Termux from the Playstore (older version). However, it is not recommended and the developer is planning to unlist it from the Playstore.

The recommended ways to download and install Termux are from Github and F-droid. After you install it, open Termux from the launcher and you will see the following screen.

Termux Application
Termux Application

Enabling Storage Access on Termux

You need to provide storage permission to access Android files or save files from the Termux app. To do so, simply execute the below command to allow storage access to Termux when prompted.

$ termux-setup-storage

Below is the output of the above command.

Enabling Storage Access in Termux
Enabling Storage Access on Termux

Now all the files will be saved in the shared folder within your Android system. If the folder does not exist, then create a new folder at the /storage/emulated/0/shared path.

Installing and Managing Termux Packages

Termux supports multiple package managers: pkg and apt. It is strongly recommended to use the pkg utility instead of apt, which is a wrapper of the PKG command that can perform a variety of tasks.

  • Use pkg in instead of pkg install or apt install.
  • It will automatically run the apt update command before installing a package.
  • Performs client-side repository load-balancing by automatically switching mirrors on a regular basis.

Update and Upgrade Repositories on Termux

Once the Termux application is open, you can execute the below command to update and upgrade repositories.

$ pkg upgrade

It is highly recommended to update and upgrade your existing repositories before installing the new package.

Installing Packages on Termux

You can easily install a new package on Termux by using the pkg in [PACKAGE-NAME] command. Replace the [PACKAGE-NAME] with your desired package.

For example, to install Python in Termux, specify Python in place of [PACKAGE-NAME], as shown below.

$ pkg in python

Below is the output of the above command.

Installing Python Package on Termux
Installing Python Packages on Termux

Now, if you run the python command on the terminal, you will get the Python interpreter, as shown below.

$ python

Below is the output of the above command.

Starting the Python Interpreter on Termux
Starting the Python Interpreter on Termux

Uninstalling Packages on Termux

Specify the package name with the pkg uninstall command to remove it from your Android device.

$ pkg uninstall python

Below is the output of the above command.

Uninstalling Python Package on Termux
Uninstalling Python Packages on Termux

It will only remove the package, but modified configuration files will be left intact. If you want to remove them, use apt purge instead.

Termux Commands Cheatsheet

Below are the common commands used in Termux.

pkg autocleanRemove outdated .deb files from the cache.
pkg cleanRemove all .deb files from the cache.
pkg files [PACKAGE-NAME]List files installed by the specified package.
pkg list-allList all available packages.
pkg list-installedList currently installed packages.
pkg reinstall [PACKAGE-NAME]Re-install specified package.
pkg search [QUERY]Search package by the query.
pkg show [PACKAGE-NAME]Show information about the specific package.

Enable Other Repositories on Termux

Official Termux repositories contain all the required packages. However, some optional repositories provide content on a specific topic that can be enabled using the following commands.

RepositoryCommand to subscribe to the repository
game-packagespkg install game-repo
science-packagespkg install science-repo
termux-root-packagespkg install root-repo
x11-packages (Android 7+ only)pkg install x11-repo

Or you can pick a mirror by using the termux-change-repo command.

Wrap Up

Termux is a very useful application but lacks some features. For example, you can easily create a Python script in Termux, but GUI applications or libraries such as TensorFlow will not work on it.

Even for penetration testing, it will lack the speed while brute-forcing and cannot perform WIFI attacks.

It is good for beginners to use to get their hands on the Linux command and programming language without purchasing a big metal box.

At some point, it will be less useful for you if you require a PC to work on real-world applications. Let us know your thoughts in the comment section.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments