Termux Commands List: The Best Guide in 2023

Termux Commands List: The Ultimate Guide

Termux is an Android terminal emulator app that provides Linux environment on mobile devices. It comes preinstalled with various useful Linux packages and command line tools. Using Termux, you can access the Linux command line interface on your Android smartphone or tablet.

In this comprehensive guide, we will go through the most commonly used Termux commands and how to use the Termux terminal effectively. Whether you are a new or experienced Termux user, this guide will help you learn all the essential Termux commands, tricks and hacks.

An Introduction to Termux

For those new to Termux, let’s first understand what is Termux and how it provides Linux environment on Android.

 What is Termux?

Termux is an open source Android terminal emulator app that allows using the Linux command line interface on Android devices. With Termux, you can run multiple Linux distros and command line tools on your Android smartphone or tablet.

Some key features of Termux include:

  • Provides Linux environment without rooting your Android device
  • Supports important Linux commands and shell utilities like Bash, ssh, git etc.
  • Allows installing various Linux based packages and software
  • Provides access to Linux file system on Android
  • Supports connecting a Bluetooth keyboard for easier terminal usage
  • Available for free on Google Play Store

Overall, Termux transforms your Android mobile into a Linux development environment without the need for rooting or installing custom mods.

 How Does Termux Work?

Termux works by providing a Linux system layer that runs as an Android app without any root permissions. It uses the following key components that make up the Termux environment:

  • procps: Provides Linux process and utility tools like top, ps, uptime etc.
  • busybox: Offers Unix shell commands and utilities through a single binary
  • clang: The C/C++ compiler that allows compiling source code on device
  • openssl: For accessing openssl commands on Android device
  • Python: Powerful interpreted programming language
  • curl: Command line tool for transferring data using URL syntax
  • Git: Distributed version control system for managing code
  • vim: Feature-rich text editor for coding on the go

This small yet powerful base allows Termux to provide a wide Linux environment. You can install other Linux packages and tools to further enhance the capabilities.

 Why Use Termux?

Here are some prominent use cases and advantages of using the Termux terminal emulator app:

  • Run Linux shell and commands on Android without rooting
  • Develop, compile, debug code on mobile devices
  • Execute Linux scripts and apps on Android
  • Install network tools like nmap, hydra, ncat etc for penetration testing
  • Analyze traffic with packet analyzer tools like tcpdump
  • Access remote servers using ssh client from mobile device
  • Enjoy programming on the go with editors like vim and emacs
  • Automate tasks on Android using cron jobs
  • Host websites and build apps for Android using Linux dev tools
  • Explore Linux and Unix systems while on the move

In short, Termux lets you access the power of Linux command line on your Android smartphone and tablet. It opens up immense possibilities for mobile programming, scripting, network analysis and Linux environment customization.

 Getting Started with Termux

Termux is available for free on the Google Play Store for all Android versions 5.0 and above. You can quickly install and start using Termux by following these simple steps:

 Installing Termux

  • Open Play Store on your Android device
  • Search for “Termux” app
  • Select the Termux app by the developer Fredrik Fornwall
  • Install the app on your device
  • Open Termux app after installing

You will now see a terminal screen with a flashing cursor, indicating Termux is ready for use.

 Running First Command

Let’s run a simple Linux command to test Termux.

Type “ls” and press Enter. This will list all files and folders in current working directory.

You will see some default folders like “dcim”, “pictures” etc. This confirms Termux can run Linux commands.

Next, type “pwd” and press Enter to print current working directory.

It will show the path as “/data/data/com.termux/files/home”. This is Termux’s default home folder.

Type “echo hello” and press Enter to echo the text. You have run your first Linux commands on Termux!

 Creating Termux Shortcut

For quick access to Termux terminal, you should create a launcher shortcut on your Android home screen. Follow these steps:

  • Go to Android home screen and tap & hold empty area
  • Select “Widgets” from popup menu
  • Search for “Termux” widget and select it
  • Place the widget on home screen. This will create a Termux shortcut.

You can now directly launch Termux terminal from the home screen instead of searching for it in app drawer every time.

 Important First Steps

After installing Termux, you should perform these important initial steps:

  • Run “apt update” to update package indexes
  • Run “apt upgrade” to install the latest package versions.
  • Install useful apps like vim, python, git using “apt
  • Customize shell by installing zsh, powerlevel10k etc
  • Setup external storage access to manage files easily
  • Install Terminator plugin for multi-window terminals
  • Enable Play Store access to install Android apps from Termux

These steps will prepare your Termux environment for the real work. We will cover these in detail in the following sections.

At this point, you have installed Termux, run initial commands and created home screen shortcut. You are now ready to start using the full power of Termux terminal emulator on your Android device.

 Important Termux Commands

Now that you have Termux installed, let’s go through the most essential Linux commands to use in Termux terminal.

 

 apt – Package Management

The “apt” command allows installing and managing apps or packages in Termux. It is one of the most frequently used commands.

  •  apt update – Update package index
  •  apt upgrade – Upgrade installed packages
  •  apt install <package> – Install a new package
  •  apt remove <package> – Uninstall an existing package

For example:

apt update

apt install wget

apt remove vim

This will update packages, install wget and remove vim editor.

 

 pkg – Alternative Package Manager

Termux has an alternative package manager called pkg with similar usage as apt.

  • pkg update – Update package list
  •  pkg install <package> – Install a package
  • pkg remove <package> – Remove an installed package

Example usage:

pkg update

pkg install python

pkg remove python

This will update packages, install python and then remove it.

 

 ls – List Files and Folders

The ls command is used to list files and folders in Linux.

  • ls – List files in current directory
  • ls -l – Use long listing format
  • ls /sdcard – List files on external SD card

For example:

ls

ls -l

ls /sdcard

This prints files in current, long and external SD card listing.

 

 cd – Change Directory

To navigate between folders, use the cd command in Termux.

  • cd foldername – Change to directory *foldername*
  • cd .. – Go to parent directory
  • cd / – Go to root directory
  • cd ~/storage/downloads – Go to downloads folder on external storage

Example usage:

cd dcim

cd ..

cd ~/storage/shared

This goes inside dcim folder, then to parent and finally downloads folder.

 

 pwd – Print Working Directory

The pwd command prints the path of current working directory.

  • pwd – Print current directory path

For example:

pwd

This will output the absolute path like /data/data/com.termux/files/home

 

 cp – Copy Files and Folders

To copy files and folders in Termux, utilize the cp command.

  • cp source destination – Copy source file/folder to destination
  • cp -r source destination – Copy source folder recursively

For example:

cp file.txt temp.txt

cp -r folder1 folder2

This will copy file.txt to temp.txt and folder1 to folder2 recursively.

 

 mv – Move and Rename Files

The mv command allows moving and renaming files in Termux.

  • mv file.txt documents – Move file to documents folder
  • mv file.txt newname.txt – Rename file to newname.txt

For example:

mv app.py temp

mv temp.txt new.txt

This will move app.py to temp folder and rename temp.txt to new.txt.

 

 rm – Remove Files and Folders

To delete files and folders, use the rm command in Termux.

  • rm file.txt – Delete file.txt file
  • rm -r foldername – Delete foldername folder recursively
  • rm -f file.txt – Force delete file without confirmation

For example:

rm temp.txt

rm -r test

rm -f temp

This will remove temp.txt, test folder and temp file forcefully.

 

 mkdir – Make New Directory

You can create a new directory using the mkdir command.

  • mkdir foldername – Create a new folder called *foldername*
  • mkdir folder1 folder2 – Create multiple folders together
  • mkdir -p test/newfolder – Create nested folder structure

For example:

mkdir temp

mkdir python cgi-bin

mkdir -p scripts/shell

This will create single temp folder, then python and cgi-bin together and finally nested scripts/shell folder.

 

 chmod – Change File Permissions

The file permissions can be updated using chmod command.

  • chmod 755 file.sh – Make file executable for all users
  • chmod 644 file.txt – Make file readable and writable for user
  • chmod -R 755 scripts – Recursively change scripts folder permissions

For example:

chmod 755 myscript.sh

chmod 644 notes.txt

chmod -R 755 python_scripts

This sets executable permission on script, readable/writable text file and recursive permission on scripts folder.

 

 cat – View File Contents

To display a file’s contents on the terminal, use the cat command.

  • cat file.txt – Print file.txt contents
  • cat -n file.txt – Print contents with line numbers

For example:

cat example.py

cat -n log.txt

This will print python file content and log file with line numbers.

 

 less – View File Page by Page

The less command allows scrolling through a text file page by page.

  • less file.txt – View text file in a paginated manner
  • Press spacebar to scroll down a page
  • Type ‘q‘ to quit out of less viewer

For example:

less longtext.txt

This will open longtext.txt in less command for page by page viewing.

 

head/tail – View Top/Bottom of File

To display first or last parts of a text file, use head and tail commands:

  • head file.txt – Output first 10 lines of file
  • tail file.txt – Output last 10 lines of file
  • head -n 20 file.txt – Show first 20 lines instead of 10
  • tail -f log.txt – Continuously monitor changes to log file

For example:

head access.log

tail -20 debug.log

tail -f app.log

This will show top 10 lines of access.log, last 20 lines of debug.log, and monitor app.log in real-time.

 

 grep – Search Text in Files

The grep command allows searching for text patterns within files.

  • grep “hello” file.txt – Find lines containing text hello in file
  • grep -r “hello” /path – Recursively search hello text in path
  • grep -i “hello” file.txt – Search hello text case-insensitively

For example:

grep “python” mycode.py

grep -r “404” /var/log

grep -i “error” app.log

This will search python in mycode.py, 404 in /var/log recursively and error case-insensitively in app.log.

 

 find – Find Files by Name

To find files by name or expression, utilize the find command.

  • find . -name “*.jpg” – Find jpg files in current directory
  • find / -name “notes.txt” – Search notes.txt starting from root
  • find ~ -type d – Find all directories in home folder

For example:

find . -name “*.png”

find /sdcard -name “*.mp3”

find ~ -type d

This will find png files in current folder, mp3 files on SD card, and all home directories.

 

 uname – Print System Information

The uname command provides information about your Termux system environment.

  • uname – Print basic OS details
  • uname -a – Print all system information
  • uname -m – Print machine hardware name

For example:

uname

uname -a

uname -m

This will print OS, all details, and hardware name for your Android device.

 

 uptime – Check System Uptime

Check the system uptime i.e. the time period for which Termux has been running, use uptime command.

  • uptime – Print current uptime details

For example:

uptime

This will output uptime details like up 2 days, 3 hours along with system load.

 

 date – Show Current Date

The date command is used to display current date and time in Termux terminal.

  • date – Print current date
  • date “+%D” – Print date in MM/DD/YY format
  • date “+%T” – Print time in HH:MM:SS format

For example:

date

date “+%D” 

date “+%T”

This will print current date, then in MM/DD/YY and HH:MM:SS formats.

 

 df – Check Disk Space Usage

To view disk storage space usage for Termux and external storage, use df command.

  • df – Print all filesystem disk usage
  •  df -h – Print in human readable format
  •  df /sdcard – Check SD card space usage

For example:

df

df -h

df /sdcard

This will show all disk usage, in easy to read format, and just the external SD card usage.

 

 du – Check Folder Space Usage

The du command allows checking disk space used by a specific folder and its contents.

  • du – Print current folder size
  •  du -h – Print size in human readable format
  • du -sh * – Print size of all folders in current location

For example:

du

du -h

du -sh *

This will display current folder size, in easy to read format, and all subfolder sizes together.

 

 top – View Running Processes

To view currently running processes in Termux, use the top command.

  • top – Display dynamic list of processes
  • top -o %MEM – Sort processes by memory usage
  • top -o %CPU – Sort processes by CPU usage

For example:

top

top -o %MEM

top -o %CPU

This will show running processes, sorted by memory and CPU usage.

 

 ps – List Processes Snapshot

The ps command provides a static snapshot of currently running processes.

  • ps – Print snapshot of processes
  • ps aux – Print details of all running processes
  •  ps aux | grep python – Print only python processes

For example:

ps aux

ps aux | grep [p]ython

This will show all processes and then only python processes.

 

 kill – Terminate Running Processes

To forcibly terminate a running process, use the kill command.

  • kill 1234 – Terminate process with ID 1234
  •  killall python – Kill all processes named python
  • kill -9 1234 – Force kill process with ID 1234

For example:

kill 4582

killall node

kill -9 8392

This will kill process ID 4582, all node processes, and force kill process ID 8392.

 

 ping – Check Network Connectivity

The ping command allows checking connectivity to a network host.

  • ping google.com – Ping google.com website
  • ping -c 5 8.8.8.8 – Ping 8.8.8.8 5 times
  • ping -i 10 192.168.0.1 – Wait 10 seconds between pings

For example:

ping google.com

ping -c 10 yahoo.com

ping -i 5 192.168.15.1

This will ping google.com, yahoo.com 10 times, and 192.168.15.1

 

READ MORE:https://ifixmywindows.com/flush-dns/

Leave a Comment