Termux is a free and open-source terminal emulator for Android that allows you to run a Linux environment on your phone. It comes with a basic set of commands that you can use to do things like navigate your file system, install packages, and run scripts.
In this blog post, we will cover some of the most basic commands in Termux. These commands will give you a foundation that you can build on as you learn more about Termux and how to use it.
Apt:
The apt command is at the heart of package management in Termux. Similar to
package managers in Linux distributions, apt allows you to install, update,
and remove packages effortlessly. Here are a few frequently used commands:
• apt update: Updates the package lists to fetch the latest information about
available packages.
• apt upgrade: Upgrades all the
installed packages to their latest versions.
• apt
install <package>: Installs a specific package.
• apt remove <package>: Uninstalls a specific package.
• apt search <keyword>: Searches for packages related to a specific
keyword.
pkg:
Another package management command in Termux is pkg. It provides similar
functionalities to apt but with a simplified syntax. Here are a few useful pkg
commands:
• pkg update: Updates the package lists.
• pkg upgrade: Upgrades all installed packages.
• pkg
install <package>: Installs a specific package.
• pkg uninstall <package>: Uninstalls a specific package.
• pkg search <keyword>: Searches for packages related to a specific
keyword.
ls:
The ls command is used to list the files and directories in the current
working directory. Here are some commonly used options:
• ls: Lists files and directories in the current directory.
• ls -l: Displays detailed information about files and directories, including
permissions, owner, size, and modification date.
• ls
-a: Shows hidden files and directories.
• ls -R:
Recursively lists all files and directories in the current and
subdirectories.
• ls -lh: Displays file sizes in a
human-readable format.
cd:
The cd command is used to change the current working directory. Here are a few
examples:
• cd: Changes to the home directory.
• cd <directory>: Changes to a specific directory.
• cd ..: Moves to the parent directory.
• cd -:
Returns to the previous directory.
pwd:
The pwd command prints the current working directory. It is especially useful
when you need to verify your location within the file system.
cp and mv:
The cp command is used to copy files and directories, while the mv command is
used to move or rename files and directories. Here are some examples:
• cp <source> <destination>: Copies a file or directory to a
specified destination.
• mv <source>
<destination>: Moves a file or directory to a specified destination or
renames it.
mkdir:
The mkdir command is used to create directories. Here's how to use it:
• mkdir <directory>: Creates a new directory with the specified name.
rm:
The rm command allows you to remove files and directories. Exercise caution
when using this command, as it permanently deletes the specified files or
directories. Here are some examples:
• rm
<file>: Removes a specific file.
• rm -r
<directory>: Deletes a directory and its contents recursively.
touch:
The touch command is used to create empty files or update the timestamp of
existing files. Here's an example:
• touch
<file>: Creates a new file with the specified name.
cat:
The cat command is used to view the contents of a file. It can also be used to
concatenate and display multiple files. Here are a couple of examples:
• cat <file>: Displays the contents of a specific file.
• cat <file1> <file2>: Concatenates and displays the contents of
multiple files.
chmod:
The chmod command allows you to change the permissions of files and
directories. Here's how to use it:
• chmod
<permissions> <file>: Changes the permissions of a specific file.
The permissions can be represented in numeric or symbolic notation.
ps:
The ps command displays information about currently running processes. Here's
an example:
• ps: Shows a list of currently running
processes.
top:
The top command provides real-time information about system resource usage and
the running processes. It's useful for monitoring system performance. To use
it, simply type top in the Termux terminal.
find:
The find command allows you to search for files and directories based on
various criteria. Here's an example:
• find
<directory> -name <filename>: Searches for a file with the
specified name in the given directory and its subdirectories.
wget:
The wget command is used to download files from the internet. Here's an
example:
• wget <URL>: Downloads a file from the
specified URL.
Ping:
The ping command is used to test the connectivity and latency between your
device and a specified network host. Here's how to use it:
• ping <host>: Sends ICMP echo requests to the specified host and
displays the round-trip time.
ifconfig/ip:
The ifconfig (or ip) command allows you to view and manage network interfaces
on your device. Here are a few examples:
• ifconfig:
Displays information about network interfaces.
•
ifconfig <interface> up/down: Brings a specific interface up or down.
• ifconfig <interface> <IP_address>: Configures a specific
interface with the given IP address.
ssh:
The ssh command enables you to establish a secure shell connection to a remote
server or device. This allows you to execute commands remotely and transfer
files securely. Here's an example:
• ssh
<user>@<host>: Initiates an SSH connection to the specified host
using the given username.
grep:
The grep command is used for pattern matching and searching within files. It
is incredibly powerful when combined with other commands. Here's an
example:
• grep <pattern> <file>: Searches
for lines in a file that match the specified pattern.
tar:
The tar command is used to create compressed archive files or extract files
from existing archives. Here are a few examples:
• tar
-cvf <archive.tar> <file1> <file2>: Creates a new tar
archive containing the specified files.
• tar -xvf
<archive.tar>: Extracts the files from an existing tar archive.
history:
The history command allows you to view the command history of your Termux
session. It's useful for recalling and reusing previously executed
commands.
• history: Displays a list of previously
executed commands.
su:
The su command allows you to switch to the superuser (root) account if your
device is rooted. It gives you elevated privileges and access to system
resources. Use this command with caution.
• su:
Switches to the root user account.
Curl:
The curl command is used for making HTTP requests from the command line. It's
a versatile tool for downloading files, interacting with APIs, and more.
Here's an example:
• curl <URL>: Retrieves the
content from the specified URL.
Alias:
The alias command enables you to create custom shortcuts for frequently used
commands. Here's an example:
• alias
<shortcut>="<command>": Creates an alias for a specific
command.
Remember to consult the documentation or refer to the man pages
(man <command>)
for further details and additional options for each command.

0 Comments