Getting Started with Termux

September 5, 2023 12 min read Sandeep Tech Team

Termux in Action

Watch this demonstration of Termux in action. The video showcases basic commands, package installation, and customization, giving you a visual overview of what's possible with a Linux environment on your Android device.

Termux is a powerful terminal emulator and Linux environment for Android that works directly with no rooting or setup required. This guide will walk you through everything you need to know to get started, from installation to mastering basic commands and unlocking the full potential of your device.

Linux
Environment
1000+
Packages Available
No Root
Required
Customizable
Interface

What is Termux?

Termux is much more than just a terminal. It's a complete Linux environment that runs on your Android device. It provides a command-line interface and allows you to install a wide range of Linux software through its package manager. With Termux, you can:

  • Learn to code in languages like Python, Ruby, and Node.js.
  • Use powerful command-line tools like Git, curl, and nmap.
  • Connect to remote servers using SSH.
  • Edit files with text editors like Nano, Vim, or Emacs.
  • Run web servers and other development tools right from your phone.

A Pocket-Sized Linux Machine

Think of Termux as turning your Android phone into a portable development and hacking machine. It's perfect for learning, experimenting, and working on projects on the go.

Why Use Termux?

Running a Linux environment on your phone offers several unique advantages:

  • Portability: Your development environment is always with you.
  • Learning: It's an excellent way to learn Linux commands and shell scripting.
  • No Root Required: Unleash powerful tools without voiding your device's warranty.
  • Cost-Effective: It's completely free and open-source.
  • Development: Write and test code, manage Git repositories, and even host a local server.
  • Security Testing: Install and use popular penetration testing tools.

Installation Guide

The installation process is simple, but it's crucial to get it from the right source.

Important: Do NOT Install from Google Play Store

The version of Termux on the Google Play Store is deprecated and no longer receives updates. Installing from the Play Store will lead to repository errors and outdated packages. You MUST install it from F-Droid.

Step 1: Install F-Droid

If you don't already have it, download and install the F-Droid app from its official website. F-Droid is an alternative app store for free and open-source software on Android.

Step 2: Install Termux from F-Droid

Open the F-Droid app, let it update its repositories, and then search for "Termux". Install the main "Termux" application. You may also want to install the "Termux: API" and "Termux: Styling" add-ons for extra functionality.

First Steps

Once you open Termux for the first time, your immediate priority is to update the package lists and upgrade any installed packages. This ensures you have the latest security patches and features.

# Update package lists and upgrade all packages pkg update && pkg upgrade -y

The `pkg update` command fetches the latest list of available packages, and `pkg upgrade` installs the newest versions of all packages you currently have installed.

Basic Linux Commands

Navigating a terminal is all about commands. Here are some of the most fundamental ones to get you started.

Termux
$ ls -a
.  ..  .bashrc  .profile
$ pwd
/data/data/com.termux/files/home
$ mkdir my-project
  • ls: List the files and directories in your current location.
  • cd: Change directory. Use cd .. to go up one level.
  • pwd: Print Working Directory (shows your current location).
  • mkdir: Make a new directory.
  • touch: Create a new, empty file.
  • rm: Remove a file.
  • nano: A simple, easy-to-use text editor.
  • clear: Clear the terminal screen.

Package Management

Termux uses the pkg command (a wrapper for APT) to manage software packages. It's incredibly powerful.

Install a Package

# Install the 'nmap' package pkg install nmap

Search for a Package

# Search for packages related to 'python' pkg search python

Uninstall a Package

# Remove the 'nmap' package pkg uninstall nmap

Customizing Termux

Granting Storage Access

To allow Termux to access your device's shared storage (like the Downloads folder), run this command once and grant permission when prompted:

termux-setup-storage

Improving the Shell

For a more user-friendly experience with features like auto-completion and themes, you can install Zsh and Oh My Zsh.

# Install zsh and git pkg install zsh git -y # Install Oh My Zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Essential Tools for Beginners

Here are a few highly recommended packages to install to get the most out of Termux.

Git

Essential for version control and cloning projects from GitHub.

Python

A versatile programming language for scripting and development.

OpenSSH

Allows you to connect to remote servers securely.

Troubleshooting Issues

Repository is Under Maintenance

Changing Repositories

If you see repository errors, your network might be blocking the default host. Run termux-change-repo and select a different mirror to resolve this.

Command Not Found

Missing a Package?

If you get a "command not found" error, it usually means the package that provides that command isn't installed. Use pkg search to find and pkg install to install it.

Security Best Practices

With great power comes great responsibility. Keep your Termux environment secure:

  • Be Cautious with Scripts: Never run scripts from untrusted sources without reviewing the code first.
  • Regular Updates: Run `pkg update && pkg upgrade` regularly.
  • Avoid Root: Termux is designed to work without root. Granting it root access can be a security risk.
  • Secure SSH: If you use SSH, always use strong, key-based authentication instead of passwords.

Security Warning

Termux gives you access to powerful networking tools. Always have permission before scanning networks or attempting to access systems that you do not own.

Interactive Demo

Try Basic Commands

Get a feel for the command line with our interactive simulator. Try running some basic commands to see what they do.

Termux
$ Type a command or click a button below

Command Reference

Essential Termux Commands

Command Description
pkg update Refreshes the list of available packages.
pkg upgrade Upgrades all installed packages to their latest versions.
pkg install [package] Installs a new package.
pkg uninstall [package] Removes a package.
ls Lists files and directories.
cd [directory] Changes the current directory.
pwd Displays the path of the current directory.
termux-setup-storage Requests permission to access shared storage.

You've now taken your first steps into the larger world of Termux. This is just the beginning. From here, you can dive into programming, ethical hacking, or simply enjoy the power of a full Linux command line on your Android device. Happy exploring!

Back to Blogs

Leave a Comment

Alex
September 6, 2023
This is the best beginner guide for Termux I've found! The tip about F-Droid saved me from a lot of frustration. Thanks!
Jenna
September 7, 2023
Wow, I had no idea my phone could do all this. The interactive demo is a really cool feature for practicing the commands.