DEV Community

Cover image for Termux: A Beginners Guide
Akhil Mahesh
Akhil Mahesh

Posted on • Originally published at rhythmusbyte.blogspot.com

Termux: A Beginners Guide

Hey everyone, I was planning to write my next article—which I mentioned in my previous post about “How to Customize the Vim Editor on Termux to Make It Look Like VSCode.” That’s when I thought: how many people actually know about Termux and how to use it? If you're one of them, this article is for you. Before diving into Termux commands, let's talk about what Termux is.

What is Termux?

Termux is a free and open-source terminal emulator for Android that provides a Linux environment without the need for root access. If your device is rooted, it becomes even more powerful, allowing you to use additional tools such as chroot. In simple terms, it transforms your Android device into a mini Linux workstation, enabling you to install extra Linux packages via its package manager (which is based on Debian’s APT).

Termux gives you access to most standard Linux commands and shells, allowing you to run scripts, compile code, and more. With Termux, you can install tools for programming (e.g., Python, JavaScript, Java), networking, security, and text editing (e.g., Vim, Nano, Emacs).

Beyond the basic terminal, Termux supports add-ons like Termux:API, Termux:Styling, and Termux:Boot, and you can install packages like OhMyZsh.

You can download Termux via F-Droid or directly from GitHub. I personally prefer the GitHub version because it's the most updated version available. You can also download it from the Play Store, but don't install it because the Play Store version is no longer actively maintained and, due to new security policies (Android 10 onward), it faces compatibility issues.

Overall, Termux is a powerful tool for developers or anyone who wishes to become a software developer but doesn't have access to a computer.

Now, let’s dive into Termux commands.

Basic Package Management

Update and Upgrade

Every time you open Termux, make sure your terminal is up-to-date by updating and upgrading it before use.

  • Update Package List:
  pkg update
  apt update
Enter fullscreen mode Exit fullscreen mode

Updates the package list from the Termux repositories.

  • Upgrade Packages:
  pkg upgrade
  apt upgrade
Enter fullscreen mode Exit fullscreen mode

Upgrades all installed packages to their latest version.

  • Combine Update and Upgrade:
  pkg update && pkg upgrade
Enter fullscreen mode Exit fullscreen mode

Alternatively, you can combine both commands in a single line.

Installing and Searching for Packages

  • Install a Package:
  pkg install <package>
Enter fullscreen mode Exit fullscreen mode

Installs a package (e.g., pkg install python).

  • Search for a Package:
  pkg search <keyword>
Enter fullscreen mode Exit fullscreen mode

Searches for packages matching the keyword.

Standard Linux File Management

These are the same commands you’d use on any Linux system:

  • ls - List files and directories
  • cd <directory> - Change the current directory (this command takes you inside a specific directory)
  • mkdir <dir> - Create a new directory (e.g., mkdir my-project)
  • cp <source> <destination> - Copy files or directories (e.g., cp files.txt home/my-folder)
  • mv <source> <destination> - Move or rename files/directories (e.g., mv files.txt home/my-folder or mv app.py application.py)
  • rm <file name> - Remove a file (deletes a file). Use rm -r for directories.
  • cat <file name> - View file contents
  • nano <file name> or vim <file name> - Edit file contents

Termux-Specific Commands

Storage and Repository Management

  • Set Up Storage:
  termux-setup-storage
Enter fullscreen mode Exit fullscreen mode

Prompts you to grant Termux permission to access your device’s storage.

  • Change Repository:
  termux-change-repo
Enter fullscreen mode Exit fullscreen mode

Allows you to change the package repository mirror for faster downloads. Select a repository mirror based on your nearest location.

Power and System Info

  • Prevent or Allow Sleep:
  termux-wake-lock
  termux-wake-unlock
Enter fullscreen mode Exit fullscreen mode

Prevents or allows the device to sleep while Termux is running.

  • Display System Info:
  termux-info
Enter fullscreen mode Exit fullscreen mode

Displays detailed information about your Termux installation environment.

Clipboard and Notifications (requires termux-api package)

  • Set or Get Clipboard Content:
  termux-clipboard-set
  termux-clipboard-get
Enter fullscreen mode Exit fullscreen mode

Retrieves or sets the Android clipboard content.

  • Open a File or URL:
  termux-open <file or url>
Enter fullscreen mode Exit fullscreen mode

Opens a file or URL with an appropriate app on your device.

Multiplexing and Process Management

  • Start a Terminal Multiplexer Session:
  tmux
Enter fullscreen mode Exit fullscreen mode

Useful for running multiple tasks simultaneously.

  • Interactive Process Viewer:
  htop
Enter fullscreen mode Exit fullscreen mode

An interactive process viewer.

Termux Add-ons

These are not commands, but apps you can install via F-Droid to expand Termux's capabilities:

  • Termux:API – Integrates Android functions into the CLI.
  • Termux:Styling – Lets you change fonts and colors.
  • Termux:Boot – Runs commands automatically at device startup.
  • Termux:Widget – Integrates Termux scripts with home screen widgets.
  • Termux:Tasker – Integrates Termux scripts for automation.

I discovered a new add-on on F-Droid while researching for this article—a plugin for Termux that enables an Android GUI for terminal applications. I haven't tested it yet, but it sounds interesting. If you want to check it out, click here.

Conclusion

These are the basic Termux commands you need right now. With these commands, you can interact with Termux and browse the internet. As you explore, you'll surely find more interesting Termux commands. By the way, with Termux you can do more than just simple tasks—you can install popular distros like Ubuntu, Debian, Arch, Kali Linux, etc. You can even run a virtual desktop and customize it as your own. That’s all I want to share with you today. If you like my article, please leave a comment—whether it's criticism or appreciation—as it would mean a lot to me and help me improve.

Top comments (1)

Collapse
 
zige_luo_470a03c52e0fdb92 profile image
zige luo

谢谢你的分享,你的见鉴和技术都很棒,与此同时我更喜欢你的态度。太赞了,兄弟。希望更新一下新的内容。