Thursday, 19 June 2025

Termux: A Complete Guide for Beginners


 

Termux: A Complete Guide for Beginners

Termux is a powerful terminal emulator and Linux environment for Android. It allows users to run command-line tools and applications on their Android devices without rooting. Whether you're a developer, ethical hacker, or just a tech enthusiast, Termux provides a full-fledged Linux experience right in your pocket.

In this blog, we'll cover:

  • What Termux is and why it's useful

  • Basic Termux commands

  • Package management

  • File operations

  • Networking tools

  • Scripting in Termux

  • Useful tips and tricks


1. What is Termux?

Termux is an Android terminal emulator that provides a Linux-like environment. It comes with its own package manager (pkg and apt) and supports thousands of command-line tools, programming languages, and utilities.

Why Use Termux?

  • Run Linux commands on Android

  • Develop and run Python, Bash, C, and other scripts

  • Use networking tools like nmapcurlwget

  • SSH into remote servers

  • Ethical hacking and penetration testing (with tools like Metasploit)

  • Learn Linux commands without needing a PC


2. Getting Started with Termux

Installation

Download Termux from:

Basic Setup

After installation, run these commands to update packages:

bash
Copy
Download
pkg update && pkg upgrade

3. Basic Termux Commands

Here are some essential commands to get started:

Navigation Commands

CommandDescription
pwdPrint current working directory
lsList files and directories
cd [directory]Change directory
cd ..Move to parent directory
cd ~Go to home directory
mkdir [name]Create a new directory
rmdir [name]Remove an empty directory

File Operations

CommandDescription
touch [file]Create a new file
cat [file]Display file content
nano [file]Edit file using Nano editor
cp [source] [destination]Copy a file
mv [source] [destination]Move or rename a file
rm [file]Delete a file
rm -rf [directory]Force delete a directory

System Information

CommandDescription
uname -aShow system information
whoamiDisplay current user
df -hShow disk space usage
topDisplay running processes
psList active processes

4. Package Management

Termux uses pkg (a wrapper for apt) to install packages.

Basic Package Commands

bash
Copy
Download
pkg update            # Update package list
pkg upgrade           # Upgrade all installed packages
pkg install [package] # Install a package (e.g., `pkg install python`)
pkg remove [package]  # Uninstall a package
pkg search [keyword]  # Search for packages
pkg list-installed    # List installed packages

Popular Packages to Install

bash
Copy
Download
pkg install python    # Python programming
pkg install git       # Git version control
pkg install wget      # Download files
pkg install curl      # Transfer data via URLs
pkg install nmap      # Network scanning
pkg install vim       # Advanced text editor

5. Networking in Termux

Termux includes many networking tools:

Basic Networking Commands

bash
Copy
Download
ping google.com       # Check internet connectivity
ifconfig              # Network interface info (requires `net-tools`)
wget [URL]            # Download a file
curl [URL]            # Fetch URL content
ssh user@host         # Connect via SSH

Setting Up an SSH Server

  1. Install OpenSSH:

    bash
    Copy
    Download
    pkg install openssh
  2. Start SSH server:

    bash
    Copy
    Download
    sshd
  3. Find your IP:

    bash
    Copy
    Download
    ifconfig
  4. Connect from another device:

    bash
    Copy
    Download
    ssh [username]@[your-ip] -p 8022

6. Scripting in Termux

You can write and execute scripts in Termux using Bash or Python.

Creating a Simple Bash Script

  1. Create a file:

    bash
    Copy
    Download
    nano hello.sh
  2. Add the following:

    bash
    Copy
    Download
    #!/bin/bash
    echo "Hello, Termux!"
  3. Save (Ctrl+O) and exit (Ctrl+X).

  4. Make it executable:

    bash
    Copy
    Download
    chmod +x hello.sh
  5. Run it:

    bash
    Copy
    Download
    ./hello.sh

Running Python Scripts

  1. Install Python:

    bash
    Copy
    Download
    pkg install python
  2. Create a Python script:

    bash
    Copy
    Download
    nano hello.py
  3. Add:

    python
    Copy
    Download
    print("Hello from Python!")
  4. Run it:

    bash
    Copy
    Download
    python hello.py

7. Useful Termux Tips & Tricks

  • Storage Access: Run termux-setup-storage to grant Termux access to device storage.

  • Customize Prompt: Edit ~/.bashrc to change the terminal appearance.

  • Run GUI Apps: Use Termux:X11 add-on for GUI applications.

  • Run Linux Distributions: Install proot-distro to run Ubuntu, Debian, etc.

    bash
    Copy
    Download
    pkg install proot-distro
    proot-distro install ubuntu
    proot-distro login ubuntu

Conclusion

Termux is a versatile tool that brings the power of Linux to Android. Whether you're learning command-line basics, coding on the go, or performing network security tasks, Termux has you covered. Start exploring and unlock the full potential of your Android device!

Next Steps

  • Try installing more packages (pkg list-all)

  • Learn Bash scripting

  • Experiment with networking tools like nmap and netcat

Happy hacking with Termux! 🚀

No comments:

Post a Comment