Termux Command List - Learn Termux

So you installed Termux on your phone thinking it would be cool to have Linux on Android and now you’re staring at this black screen with a cursor blinking at you. Yeah that’s normal. Termux is basically Linux terminal on your phone which sounds awesome until you realize you have no idea what commands actually do anything useful.

Most Termux tutorials either assume you already know Linux or they show you three basic commands and call it a day. Neither helps when you want to actually do stuff with this thing.

What Even Is Termux

Termux is a terminal app that gives you Linux environment on Android without rooting your phone. You can install programming languages, run servers, use command line tools, basically turn your phone into a tiny Linux computer. Pretty cool except learning command line from scratch on a phone keyboard is kind of torture.

The good news is you don’t need to memorize hundreds of commands to do useful stuff. There are maybe 20-30 commands that handle 90% of what normal people want to do.

Most Common Commands

These are the commands you’ll probably use every single day. Learn these first and you can do most basic stuff.


ls

Lists files and folders in current directory. Your most used command.


cd foldername

Changes to that folder. Use cd .. to go back up.


pwd

Shows where you are right now. Useful when you get lost.


mkdir newfolder

Creates new folder. Basic but you’ll use it constantly.


nano filename.txt

Opens file in text editor. Easiest editor for beginners.


pkg install python

Installs software. Replace python with whatever you want.


pkg update

Updates package list. Run this before installing new stuff.


python script.py

Runs Python script. Works for any programming language.


rm filename

Deletes file. Be careful, no trash can to recover from.


cp oldfile newfile

Copies file. Good for making backups before editing.

Moving around and managing files. You’ll use these constantly.


pwd

Shows current directory path.


ls

Lists files and folders in current directory.


ls -l

Shows detailed file info including sizes and dates.


ls -la

Shows all files including hidden ones that start with dots.


ls -lh

Shows file sizes in readable format like KB, MB, GB.


cd foldername

Changes to that folder.


cd ..

Goes up one directory level.


cd ~

Goes to your home directory.


cd /

Goes to root directory of entire system.


cd /sdcard

Goes to phone storage where your photos and downloads live.


cd /sdcard/Download

Goes directly to Downloads folder.


mkdir newfolder

Creates new folder in current directory.


mkdir -p path/to/folder

Creates nested folders even if parent folders don’t exist.


rmdir emptyfolder

Removes empty folder only.


rm filename

Deletes single file permanently.


rm -r foldername

Deletes folder and everything inside it.


rm -rf foldername

Force deletes folder without asking confirmation.


cp file1 file2

Copies file1 to new file called file2.


cp -r folder1 folder2

Copies entire folder and all contents.


mv oldname newname

Renames file or moves it to new location.


mv file.txt /sdcard/

Moves file to phone storage.

Package Management

Installing and managing software in Termux. Always update before installing new stuff.


pkg update

Updates the list of available packages.


pkg upgrade

Updates all installed packages to newest versions.


pkg install python

Installs Python programming language.


pkg install git

Installs Git version control system.


pkg install nano

Installs nano text editor.


pkg install curl

Installs curl for downloading files.


pkg install wget

Installs wget for downloading files.


pkg install nodejs

Installs Node.js JavaScript runtime.


pkg install gcc

Installs GCC compiler for C programs.


pkg install htop

Installs better version of top command.


pkg install tree

Installs tree command for showing folder structure.


pkg search editor

Searches for packages containing “editor”.


pkg list-installed

Shows all currently installed packages.


pkg show python

Shows detailed information about python package.


pkg uninstall python

Removes python package completely.


apt update

Same as pkg update, alternative command.


apt install python

Same as pkg install python.


apt upgrade

Same as pkg upgrade.

File Viewing and Editing

Reading and editing files from command line. Start with nano editor, it’s easiest.


cat filename.txt

Shows entire file content at once.


less filename.txt

Views file with scrolling, press q to quit.


more filename.txt

Similar to less but simpler, space to scroll down.


head filename.txt

Shows first 10 lines of file.


head -n 20 filename.txt

Shows first 20 lines of file.


tail filename.txt

Shows last 10 lines of file.


tail -f logfile.txt

Follows file as new lines are added, great for logs.


tail -n 50 filename.txt

Shows last 50 lines of file.


nano filename.txt

Opens file in nano editor, easiest for beginners.


vim filename.txt

Opens file in vim editor, harder but more powerful.


emacs filename.txt

Opens file in emacs editor, install first with pkg.


touch newfile.txt

Creates empty file or updates timestamp.


file filename.txt

Shows what type of file it is.


stat filename.txt

Shows detailed file information and permissions.

Network and Download

Downloading files and network testing. Curl and wget do basically the same thing.


curl -O https://example.com/file.zip

Downloads file and saves with same name.


curl -o newname.zip https://example.com/file.zip

Downloads file and saves with different name.


curl -L -O https://short.url/file

Downloads following redirects, needed for short URLs.


wget https://example.com/file.zip

Downloads file with wget instead of curl.


wget -O newname.zip https://example.com/file.zip

Downloads and saves with different name.


ping google.com

Tests internet connection to Google.


ping -c 4 google.com

Pings 4 times then stops automatically.


traceroute google.com

Shows route packets take to reach destination.


nslookup google.com

Shows IP address for domain name.


ssh user@server.com

Connects to remote server via SSH.


scp file.txt user@server:/path/

Copies file to remote server.


rsync -av folder/ user@server:/backup/

Syncs folder to remote server efficiently.

Programming Languages

Running code and development tools. Install languages first with pkg install.


python script.py

Runs Python script file.


python3 script.py

Runs Python 3 specifically if you have multiple versions.


python -c "print('Hello World')"

Runs Python code directly from command line.


node script.js

Runs JavaScript file with Node.js.


node -e "console.log('Hello World')"

Runs JavaScript code directly.


gcc program.c -o program

Compiles C source code into executable.


./program

Runs compiled program in current directory.


javac Program.java

Compiles Java source code.


java Program

Runs compiled Java program.


php script.php

Runs PHP script.


ruby script.rb

Runs Ruby script.


go run program.go

Runs Go program.


rustc program.rs

Compiles Rust program.

Git Version Control

Managing code with Git. Essential for any programming work.


git clone https://github.com/user/repo

Downloads entire repository from GitHub.


git status

Shows current changes in working directory.


git add filename.txt

Stages specific file for commit.


git add .

Stages all changes for commit.


git commit -m "commit message"

Commits staged changes with message.


git push

Uploads commits to remote repository.


git pull

Downloads latest changes from remote repository.


git log

Shows commit history.


git diff

Shows changes since last commit.


git branch

Lists all branches.


git checkout branchname

Switches to different branch.


git init

Initializes new Git repository in current folder.

System Information

Checking system resources and running processes. Good for troubleshooting.


ps

Shows currently running processes.


ps aux

Shows all processes with detailed information.


top

Live view of system resources, press q to quit.


htop

Better version of top with colors and mouse support.


df -h

Shows disk space usage in readable format.


du -h foldername

Shows how much space folder uses.


du -sh *

Shows size of everything in current directory.


free -h

Shows memory usage in readable format.


uname -a

Shows system information and kernel version.


whoami

Shows current username.


id

Shows user ID and group information.


date

Shows current date and time.


uptime

Shows how long system has been running.


which python

Shows full path to python executable.


whereis python

Shows all python-related files and locations.

Text Processing

Searching and manipulating text files. Super useful for logs and data.


grep "search term" filename.txt

Finds lines containing specific text.


grep -r "term" *

Searches for text in all files recursively.


grep -i "term" filename.txt

Case-insensitive search ignores upper/lower case.


grep -n "term" filename.txt

Shows line numbers with search results.


grep -v "term" filename.txt

Shows lines that don’t contain the term.


sort filename.txt

Sorts lines alphabetically.


sort -n numbers.txt

Sorts numbers in numerical order.


sort -r filename.txt

Sorts in reverse order.


uniq filename.txt

Removes duplicate consecutive lines.


wc filename.txt

Counts lines, words, and characters.


wc -l filename.txt

Just counts number of lines.


wc -w filename.txt

Just counts number of words.


cut -d',' -f1 file.csv

Extracts first column from CSV file.


awk '{print $1}' filename.txt

Prints first column of space-separated file.


sed 's/old/new/g' filename.txt

Replaces all occurrences of “old” with “new”.

Archive and Compression

Creating and extracting compressed files. Useful for backups and downloads.


tar -xzf archive.tar.gz

Extracts tar.gz compressed file.


tar -czf backup.tar.gz folder/

Creates compressed tar.gz archive of folder.


tar -tf archive.tar.gz

Lists contents of tar.gz file without extracting.


zip -r backup.zip folder/

Creates ZIP archive of folder.


unzip archive.zip

Extracts ZIP file.


unzip -l archive.zip

Lists contents of ZIP file without extracting.


gzip filename.txt

Compresses single file with gzip.


gunzip filename.txt.gz

Decompresses gzip file.


7z x archive.7z

Extracts 7-zip archive if 7z is installed.

Termux-Specific Commands

These only work in Termux because they interact with Android features.


termux-setup-storage

Gives Termux access to phone storage, run this once.


termux-info

Shows Termux version and configuration details.


termux-reload-settings

Reloads Termux configuration without restarting.


termux-wake-lock

Prevents phone from sleeping during long tasks.


termux-wake-unlock

Allows phone to sleep normally again.


termux-battery-status

Shows detailed battery information in JSON format.


termux-camera-info

Shows available cameras and their capabilities.


termux-camera-photo pic.jpg

Takes photo with default camera and saves it.


termux-clipboard-get

Gets current clipboard content.


termux-clipboard-set "text"

Sets clipboard to specific text.


termux-notification --title "Title" --content "Message"

Shows Android notification with custom text.


termux-toast "Hello World"

Shows toast notification at bottom of screen.


termux-vibrate

Makes phone vibrate briefly.


termux-torch on

Turns on camera flashlight.


termux-torch off

Turns off camera flashlight.


termux-wifi-connectioninfo

Shows current WiFi connection details.

File Permissions

Managing file permissions and ownership. Advanced stuff most people don’t need.


chmod +x script.sh

Makes file executable so you can run it.


chmod 755 filename

Sets read/write/execute for owner, read/execute for others.


chmod 644 filename

Sets read/write for owner, read-only for others.


ls -l filename

Shows current file permissions.


chown user:group filename

Changes file owner and group.


ln -s /path/to/file linkname

Creates symbolic link (like shortcut).


readlink linkname

Shows where symbolic link points to.


find . -name "*.txt"

Finds all txt files in current directory and subdirectories.


find . -type f -size +1M

Finds files larger than 1 megabyte.


find . -mtime -1

Finds files modified in last 24 hours.

Process Management

Managing running programs and background tasks.


command &

Runs command in background, returns to prompt immediately.


jobs

Shows background jobs running in current session.


fg

Brings most recent background job to foreground.


bg

Sends stopped job to background.


kill 1234

Kills process with ID number 1234.


killall processname

Kills all processes with that name.


pkill python

Kills all python processes.


nohup command &

Runs command that survives terminal closing.


screen

Creates detachable terminal session.


tmux

Better terminal multiplexer, install first with pkg.


tmux new -s sessionname

Creates new tmux session with specific name.


tmux attach -t sessionname

Attaches to existing tmux session.

Quick Shortcuts and Tips

Essential keyboard shortcuts and time-savers you should know.


history

Shows list of previous commands you ran.


history | grep install

Searches command history for “install”.


!!

Repeats last command exactly.


!123

Runs command number 123 from history.


clear

Clears terminal screen.


exit

Closes current terminal session.


man command

Shows manual page for command if available.


command --help

Shows help information for most commands.



which command

Shows full path where command is installed.


alias ll='ls -la'

Creates shortcut so “ll” runs “ls -la”.


echo "Hello World"

Prints text to screen.


echo $HOME

Shows value of HOME environment variable.

Remember to use tab completion - start typing filename then press tab and it completes automatically. Up arrow scrolls through previous commands so you don’t have to retype everything. These shortcuts save tons of time once you get used to them.