Termux is an open source Android terminal emulator software that provides a command line interface with a Linux environment, providing users with a series of powerful functions and open source software packages, and can perform various tasks such as programming, network operations, security testing, etc. on mobile devices.
1. What is Termux?
Termux is a Linux emulator for Android phones that can simulate a Linux environment on the phone. It provides a command line interface for users to interact with the system.
It is just an ordinary mobile app that can be downloaded and installed from the app store. No root permissions are required, and no settings are required. You can use it by opening it.
2. Environment preparation
After opening Termux, it is a full-screen command line interface. Although you can use the touch keyboard of the phone to enter commands, it is recommended to use a Bluetooth keyboard.
The first step is to update the system to ensure that the latest version is used.
# Connect to the remote repository and obtain package information
$ apt update
# Update the locally installed package
$ apt upgrade
The second step is to test the system.
# Install the sl package
$ apt install sl
# Run
$ sl
The above command installs the test package sl and then runs it. If everything is normal, a command line animation of a train will be displayed.
The third step is to access the local storage
By default, the mobile app can only access its own data. If you want to access the storage of the phone, you need to request permission.
$ termux-setup-storage
After executing the above command, a dialog box will pop up, asking whether to allow Termux to access the phone storage. Click "Allow".
This will generate a storage subdirectory in the current directory, which is a symbolic link to the phone storage. The files downloaded later will be downloaded from this directory.
3. Package management
In addition to the apt command, Termux also provides the pkg command for package management.
# Install a package
$ pkg install [package name]
# Uninstall a package
$ pkg uninstall [package name]
# List all packages
$ pkg list-all
In fact, the underlying layer of pkg[3] is apt, but it will execute apt update once before running to ensure that the latest version is installed. Therefore, apt install sl is basically equivalent to pkg install sl.
The list of packages supported by Termux can be viewed here[4].
4. Node.js
Next, install Node.js.
$ apt install nodejs
After the installation is complete, you can run JavaScript scripts. For example, create a new script hello.js.
// hello.js
console.log('hello world');
Then, execute this script.
$ node hello.js
hello world
V. Set up the server
Now, run the HTTP server through Node.js.
First, install the npm module http-server[5].
$ npm install -g http-server
Then, run the server.
$ http-server
Under normal circumstances, the command line will prompt that the server is already running on port 8080, and will also prompt the externally accessible IP address.
For example, the LAN IP of the mobile phone is 192.168.2.6, then we visit http://192.168.2.6:8080 through the desktop computer's browser, and we can see the root directory of Termux. Enter the storage subdirectory below, and you can download the mobile phone file.
If the mobile phone and computer are not in the same LAN, you can turn on the hotspot function of the mobile phone, let the desktop computer access the Internet through the mobile phone hotspot, and then access the HTTP server of the mobile phone.
By the way, the following command can be used to view the IP address of the mobile phone from the command line.
$ apt install net-tools
$ ifconfig
VI. Python
It is also possible to use other methods to set up HTTP Server without using Node.js. The following demonstrates the Python method.
$ apt install python
$ python -m http.server 8080
Then, the desktop computer can access the mobile phone.
Termux is a very powerful tool. In addition to the above method, you can also set up an Apache server[6] or access the mobile phone through other methods[7] (FTP, SSH, Rsync), which will not be introduced in detail here.
To install Python in Termux, you can use the following steps:
Launch Python
Update and upgrade your package repository
Install Python 3 using the command PKG install python
Wait for the download to finish
You can also install Python using pyenv:
Exit and restart Debian
Run pyenv versions to list all installable versions
Run pyenv install version to install the desired Python version
Run touch /root/.pyenv/version && echo "your_version_here" > /root/.pyenv/version
Run python3 -V to verify if PATH works
AudioLab
1.2.37 for AndroidNov 19, 2024 / 40.6M DownloadVoice Recorder
74.1 latest versionNov 19, 2024 / 9.1M DownloadMicrosoft Launcher
6.241002.0.1160250 latest versionNov 19, 2024 / 55.4M DownloadAPKPure
3.20.2404 for AndroidNov 19, 2024 / 16.9M DownloadOKX
6.95.1 for AndroidNov 19, 2024 / 271.4M DownloadMicrosoft Bing
29.7.421115028 latest versionNov 19, 2024 / 74.3M DownloadGoogle Docs
1.24.462.00.90 latest versionNov 19, 2024 / 105.4M DownloadGoogle Play Store
43.6.34-31 for AndroidNov 18, 2024 / 64.1M DownloadOpera
85.7.4500.82229 latest versionNov 18, 2024 / 128.1M DownloadGoogle Translate
8.20.71.687383449.1-release latest versionNov 18, 2024 / 44.6M Download