What is Termux?
In a Linux distribution, a “package” refers to a compressed file archive that contains all the files that make up a particular application. The files are usually stored in packages according to the existing installation path. Common types of Linux packages such as .deb, .rpm, and .tgz
Android is Linux
So the Android cellphone that you currently hold is a Linux. Linux is famous for its powerful reputation, OS server, internet life, and hacking.
Termux is a terminal emulator application
Termux provides Linux environment
- Public folders such as / bin, / etc, / usr, / tmp and / var do not exist.
- The android directory structure does not follow the standard rules of the Linux directory structure in general. For example, in general, Linux binary files exist in / bin while in android/system/bin.
- In the standard / general Linux folder ($ HOME) is created for each user in / home/username (multi-user), while in the android folder ($ HOME) is in the subdirectory of the application, so each application has its own folder ($ HOME) -alone. So avoid storing important data in the folder ($ HOME) when using TERMUX, because this folder will be deleted if TERMUX is uninstalled.
- Termux installs the package in the directory based on the $PREFIXenvironment variable definition (example: binaries are in $PREFIX/bin, and configuration files $PREFIX/etc). To view the contents of the $ PREFIX variable you can type echo $ PREFIX in your TERMUX terminal.
- Shared libraries are installed at $ PREFIX/lib, which has been defined in the $ LD_LIBRARY_PATH variable. This might clash with the Android system binaries in / system/bin, which can force LD_LIBRARY_PATH to be removed before running the system binaries.
- In addition to the different android file systems with Linux in general, TERMUX is run by a single user without root access (Each android application is run by the user himself), so running Linux commands on TERMUX will not affect other applications.
Access shell Linux with Termux
Access Android Shell
Development and experiment Environments
In the past, if you wanted to hack you had to use a laptop that had a Linux operating system installed, with Termux you can directly use your cell phone as a hacking tool because Android is one of the Linux variants.
Termux provides software repositories, and there are already tools for hacking that you can use to facilitate testing/auditing of security systems such as hydra, Nmap, Metasploit, net hunter times, etc.
How to install Termux on Android
- open the google play store
- type the keyword “Termux” in the search box and press search
- after finding Termux tap on the install button
- wait for the installation process to finish
- after the installation process is complete you should find the TERMUX launcher on your home screen, just tap to open TERMUX on your android
How to install applications in Termux
Termux Repository Software
For a repository (package/application) to be categorized and included in the Official repository, the repository must provide a “build script” for cross-compilation purposes so that packages can be compiled on all supported devices.
While packages built on a device and then packaged using “termux-create-package” cannot be categorized and included in the official repository.
All repositories with build scripts on the github.com/termux repo are managed and verified by signature by an officer on the Termux team.
In addition to the Official repository / official repository managed by the TERMUX team, there is also a community repository which is a repository made by individuals.
You can even create and manage it if you are a developer and want to distribute the application/package that you made to the world, the concept is the same as PPA on Ubuntu Linux.
After you finish creating the application you can package the application using termux-apt-repo from the shell to become a repository and put it on Github as hosting. </ br>
It’s important to know that Github has a limit of 100MB per file and if your repository exceeds 1GB, you will be reprimanded by GitHub to reduce the repository size.
So if you have a very large package you should use a different hosting and select hosting according to the type of file, for example, video files can be hosted on youtube.com
A. How to Install Applications in Termux from the APT repository
With pkg you will find it easier to install and upgrade packages automatically without having to manually update apt lists by typing apt update like when using the apt package manager.
LOOKING FOR PACKAGES: Use the command pkg search <package name> to search packages by name.
For example, pkg search TBomb.
INSTALL PACKAGES: Use the command pkg install <package name> to install packages.
DELETE PACKAGES: Use the command pkg uninstall <package name> to delete packages.
REINSTALL PACKAGES: Use the command pkg reinstall <package name> to reinstall packages.
PACKAGES INFORMATION: Use the command pkg show <package name> to display detailed information about packages.
FEATURING INSTALL PACKAGES: Use the command pkg list-installed to display a list of packages installed in your Termux.
SEE LOCATION OF PACKAGES: Use the command pkg files <package name> to view the location of installed files packages.
SHOW ALL PACKAGES AVAILABLE: Use the command pkg list-all to display all packages provided in the repository.
UPDATE AND UPGRADE INSTALLED PACKAGES: Use the command pkg upgrade to update and upgrade packages installed in your Termux.
B. How to Install Applications in Termux in the form of File *. Deb
UNINSTALL * .deb PACKAGES: Use the command dpkg –remove package_name to delete packages that were previously installed using the dpkg command.
VIEWING APPLICATIONS *. Deb: Use the command dpkg -l to view a list of the *. Deb applications that are installed on Termux.
Because dpkg has many useful options, you can see the manual via man dpkg.
C. How to Install the Applications for Termux in the Form of a Script
If the script that you get comes from interpreter programming languages such as python (*. Py), Perl (*. Pl), or ruby (*. Rb) then you can directly run the script without compiling it, provided you have installed the programming language. in your Termux.
Install Perl, ruby , and python on your Termux by typing the command pkg install perl ruby python
to run the Termux application in the form of a script just use the command perl script_mu.pl or ruby script_mu.rb or python script_mu.py.
Manage Application Script in Termux
Programming Language Package Manager
Some programming languages have their own package manager, the package manager for each programming language is not included by default in Termux, so you need to install it manually if you want to use it while learning Termux.
Learn to Use Termux Command
Termux Commands are case sensitive
List of Basic Termux Commands
Here are the basic Termux commands that you must master when learning to use Termux, this command code is very useful because this Termux code is often used to install, manage applications, files, and folders if you are serious about learning to hack you should get used to using the Termux command code below :
- pkg help
to see the options provided by the TERMUX pkg package manager.
- pkg search <package name>
for packages by name.
- pkg install <package name>
to install packages.
- pkg uninstall <package name>
to delete packages.
- pkg reinstall <package name>
to reinstall packages.
- pkg show <package name>
to display detailed information about packages.
- pkg list installed
to display the list of packages installed in your Termux.
- pkg files
to view the location of installed files packages.
- pkg list-all
to display all packages provided in the repository.
- pkg upgrade
to update and upgrade packages installed in your Termux.
This basic command is used to clean the console window.
pwd (print working directory), used to see the position of the current directory location.
used to view/list files and directories. use ls -lha to view detailed information from files and folders.
Used to navigate/move to another directory that we want, use it cd .to return to the directory level, use it cd ~ to go to the home directory.
Used to copy/copy files and folders.
Used To move files and folders or can be used to rename if the file/folder has the same origin and destination.
Used to delete files.
rm -rf namaFolder to delete the folder and its contents.
Used to delete an empty Folder.
rmdir –ignore-fail-on-non-empty folder name to delete a non-empty folder.
Used to change File / folder permissions / privilege.
chmod +x Folder name to change permission to 775 or rwx – x – x.
How to hack using Termux
Termux can be used for a variety of things including as a hacking tool, you can turn your Android phone into a sophisticated hacking tool just by installing the Termux in which the haking tools installed are commonly used by ethical hackers (professional penetration testers).
I have listed some main tools which are used for hacking and penetration testing. You can install these tools on Termux:
- Metasploit Framework: Metasploit is a very popular hacking tool, with this tool you can create, test, and run an exploit to exploit vulnerabilities on a system as an entry point to take over the system.
- Wireshark: Wireshark is an application for analyzing packages in a network. This application is commonly used to analyze networks, troubleshooting networks, developing software and communication protocols as well as tools in teaching and learning. You can install the Wireshark application on your android mobile with Termux for hacking purposes, where with this tool you can get a lot of information on a network that you want to hack.
- Nmap: Nmap is a network scanner application, Nmap is used to find computers and services on a computer network on how to send packets and analyze the responses received. Nmap provides a number of features for probing computer networks, including for finding hosts and services and detecting the operating system used. Come hurry up install Nmap on your Android cellphone if you want to scan the network and see who is on the same network as you or you want to get information from a host computer.
- Other tools: there are hundreds or even thousands of tools that are made for specific purposes when hacking, so you can find them yourself on the internet hacking tool that suits your needs.
Termux is a terminal emulator for accessing the Linux shell on your android, if you have a GUI based application then you will not be able to run the application/package in Termux directly and you will see a warning ” TERMUX ERROR” Gtk-WARNING **: cannot open display:: 0.0 “
This is because Termux does not find a display that will be used by the application, to overcome this you have to activate the GUI on Termux first.
Backup and restore Termux
After all this time you learn Termux and work with Termux on Android such as installing, trying, setting up various applications on Termux, of course, you don’t want all your hard work to be lost instantly caused by glitch/error on Termux applications or damage to your Android phone.
Why should you Backup Termux
To overcome and prevent this bad thing from happening, Termux has provided an application/package restic that you can install and use to backup or restore the backup results.
FIX storage permission denied Termux
How to backup Termux
To be able to backup Termux easily and safely you should use the restic application, if not you can install it first with the command pkg install restic
- Create a directory to store backups on the Sdcard with the command mkdir -p /sdcard/termux-backups
- Make the local directory that you have created a local repository with the command restic init -r /sdcard/termux-backups.
In this process, you will be asked to create a password (after making it until you forget or your backup results cannot be used)
- Start the backup process by typing the command restic backup -r /sdcard/termux-backups –tag termux $PREFIX.
- Restic applies a single incremental backup method, so even if you back up many times the result there is only 1 backup file with a change in size according to the number of packages in your Termux.
So it’s not usa worrying about full storage because of frequent backups. To do the backup again just type the command restic backup -r /sdcard/termux-backups –tag termux $PREFIX.
How to restore Termux
How to restore the following Termux assuming the backup file is located in “/ sdcard / termux-backups” if the backup location is different you can adjust the commands you will run.
Make sure you have installed the Restic application first if you haven’t installed it first by running the pkg install unstable-repo last command pkg install restic
The process of restoring Termux is a bit complicated compared to how to backup Termux because we will delete the existing environment and replace it with a backup environment.
- Copy the restic application to $ HOME, so that the restic can be run directly from the current working directory location (by default in $ HOME) by typing the command cp $PREFIX/bin/restic $HOME/restic and to make sure you are at home run the command cd ~.
- Unset LD_PRELOAD (disable termux-exec) with the command unset LD_PRELOAD.
- Delete the old $ PREFIX with the command rm -rf $PREFIX.
- Restore Termux from the Termux-backups folder with the command $HOME/restic restore -r /sdcard/termux-backups –tag termux –target / latest.
If everything is done properly you should have successfully restored the Termux from the backup file, just close the Termux application then run again and enjoy.