Best Termux Commands For Android Devices – OrcaCore
This tutorial provides you with a List of Termux Commands For Android Devices. As you know, Termux is essentially a Linux terminal emulator for Android. This allows you to leverage the power of the command line directly on your Android device to perform various tasks.
Termux commands mirror Linux commands. You can utilize them for system administration, software development, and general task automation, all from the convenience of your Android device.
The primary package managers within Termux are pkg
and APT
. These powerful tools enable you to easily manage applications and software packages on your Android device. Let’s delve into the essential commands.
You can find a comprehensive list of Termux Commands For Android Devices and practical examples on the Orcacore website, as detailed below.
To effectively use the following Termux Commands For Android Devices, ensure you have Termux properly installed on your Android device. You can follow this guide on Orcacore to help you with the Termux Setup on Android with Andronix.
Once you’ve completed the Termux installation on your Android device, proceed through the rest of this article to explore a detailed overview of Termux Commands For Android Devices.
Step 1. List of Package Management Commands For Termux Android Devices
In this section of Termux Commands For Android Devices, we’ll present a list of commands that facilitate package management within Termux, covering tasks such as installing, removing, and updating software packages.
Termux Management Commands | Usage |
---|---|
pkg search package-name |
Search for a Package |
pkg install package-name |
Install a Package |
pkg uninstall package-name |
Uninstall a Package |
pkg reinstall package-name |
Reinstall a Package |
pkg show package-name |
Show package information in detail |
pkg list-installed |
Get a list of Installed packages |
pkg list-all |
Get a list of Available Packages in Termux |
pkg autoclean |
Remove Unwanted Packages |
pkg clean |
Clean up the cache of downloaded packages |
pkg files package-name |
Display package location |
pkg update |
Update Termux packages |
pkg upgrade |
Upgrade Termux packages |
With these Termux package management commands at your disposal, you’re equipped to efficiently manage software on your Android device.
For example, you can use the following command in Termux to search for a package named OpenJDK:
pkg search openjdk
After finding your desired package, install it using the command below. In this instance, we’ll install OpenJDK 17.
pkg install openjdk-17 -y
Upon completion of the installation, you can verify the installed package location with the following command:
pkg files openjdk-17
Step 2. List of Shell Commands in Termux
This segment of Termux Commands For Android Devices provides you with a list of fundamental shell commands for your Android device. These commands are analogous to those found in Linux. Let’s explore some of these commands and their respective functions.
Termux Shell Commands | Usage |
---|---|
su |
Change Shell User |
date |
Display current date |
passwd |
Change or Set a User password |
whoami |
Display current User ID, Group, and Privileged Information |
cal |
Show Calendar |
help |
Used to display shell command information |
uptime |
Show your OS uptime |
find |
Search for your files |
ifconfig |
Configure Network Interfaces |
netstat |
Display network connections, routing tables, interface statistics, etc. |
history |
Display previously run commands |
exit |
Close Termux Terminal |
These are just a few of the basic shell commands you can utilize within Termux. You can seamlessly execute Linux commands in your Termux terminal on your Android devices.
For example, we can run the following commands in our Termux terminal and get the following results:
Step 3. List of Termux File Management Commands
The following list outlines the file management commands available in Termux.
Termux File Management Commands | Usage |
---|---|
ls |
List of Files and Directories information |
touch file-name |
Make a new file |
cat file-name |
Display file information |
cp |
Copy a file |
mv |
Move a file |
rm file-name |
Remove a file |
rm -rf directory-name |
Force delete directory |
mkdir directory-name |
Make a new directory |
rmdir directory-name |
Remove directory |
cd directory-name |
Switch to directory |
pwd |
Display the current working directory |
chmod 777 file-name |
Make the file executable for anyone |
Step 4. Install Useful Termux Repositories on Android
Upon installing Termux on your Android device, you can configure it to install packages from specialized repositories, enhancing its functionality.
Termux Root Repository
This repository enables the installation of packages exclusive to the Termux Root repository. To install it, execute the following command:
pkg install root-repo
Termux Unstable Repository
Utilize this repository to install packages from an unstable repository within Termux. You can accomplish this by running the command below:
pkg install unstable-repo
Termux X11 Repository
X11 refers to the protocol for the X Window System graphical server. This repository allows you to install packages related to it. To do this, run the following command:
pkg install x11-repo
Storage Setup for Termux
You can effortlessly grant Termux access to your SD card storage. To do so, execute the following command:
termux-setup-storage
This command typically resolves most SD card-related issues.
Step 5. Most Useful Termux Tools on Android Devices
In this section about Termux Commands For Android Devices, we’ll showcase a selection of useful tools that aren’t installed by default in Termux.
One such tool is the wget command. This tool is invaluable for downloading files from the internet. To install wget, run the command below:
pkg install wget
Another indispensable tool is the zip command. This tool empowers you to compress and uncompress files. To install zip in Termux, execute the following command:
pkg install zip
Given the prevalence of Python in numerous applications, having Python installed on your device is highly recommended. To install it, you can run the following command:
pkg install python
For further details regarding Termux Commands For Android Devices, refer to the Termux Official website.
Conclusion
At this point, you’ve explored a comprehensive List of Termux Commands For Android Devices, encompassing Package Management, File Management, and Basic shell commands. As demonstrated, these commands are analogous to Linux commands, enabling you to seamlessly utilize Linux commands on your Android device via Termux. Furthermore, you’ve learned to install useful Termux repositories and tools.
Hope you found this helpful. You may also find the article on How To Install Metasploit on Android with Termux interesting.
Alternative Solutions for Managing Android Devices via Command Line
While Termux offers a powerful and versatile way to interact with your Android device using a command-line interface, there are alternative approaches that might be more suitable depending on your specific needs and technical expertise. Here are two different ways to achieve similar results:
1. Using ADB (Android Debug Bridge):
ADB is a command-line tool that comes as part of the Android SDK (Software Development Kit). It allows you to communicate with an Android device connected to your computer via USB. While it requires a computer to operate, it provides a deeper level of system access than Termux, especially for tasks that require root privileges (on rooted devices).
-
Explanation: ADB works by establishing a connection between your computer and your Android device. Once connected, you can execute various commands to install/uninstall apps, transfer files, run shell commands, debug applications, and more. ADB is particularly useful for developers who need to test and debug their apps on a real device.
-
How it Differs from Termux: Termux runs directly on the Android device, providing a self-contained Linux environment. ADB, on the other hand, uses the Android system itself and requires a separate computer to issue commands.
-
Code Example:
First, ensure you have the Android SDK installed on your computer and ADB added to your system’s PATH environment variable. Then, enable USB debugging on your Android device in the developer options. Connect your device to your computer via USB.
To install an APK file:
adb install myapp.apk
To push a file from your computer to the device:
adb push myfile.txt /sdcard/
To execute a shell command on the device:
adb shell ls /sdcard/
2. Utilizing a Remote Shell via SSH:
This approach involves setting up an SSH server on your Android device, allowing you to connect to it remotely from another device (computer, smartphone, etc.) over a network. This provides a similar experience to Termux, but with the added benefit of remote access.
-
Explanation: SSH (Secure Shell) is a cryptographic network protocol that enables secure communication between two devices. By installing an SSH server on your Android device, you can remotely access a command-line interface and execute commands as if you were physically present.
-
How it Differs from Termux: Termux provides a local terminal environment directly on the device. Using SSH allows you to access the device’s terminal from anywhere with a network connection, making it suitable for remote administration and automation.
-
Code Example:
First, install an SSH server app on your Android device. There are several options available on the Google Play Store. One popular choice is "Termux:SSH" which works well in conjunction with Termux.
After installing the SSH server app, configure it with a username and password (or use key-based authentication for improved security). The app will typically display the SSH connection details (IP address and port number).
On your remote device (e.g., your computer), use an SSH client (such as
ssh
on Linux/macOS or PuTTY on Windows) to connect to the Android device:ssh username@android_ip_address -p port_number
Replace
username
with the username you configured on the SSH server,android_ip_address
with the Android device’s IP address, andport_number
with the port number specified by the SSH server app. After successful authentication, you will have a remote shell on your Android device.