preface

As we all know, now programmers because of work, personal interests and so on the demand for a variety of systems is growing, part of the computer or double system. Among them, there are various emulators and virtual machines running Android and Linux on Windows, which we are probably used to. Android running Windows on Android is also an interesting new feature made by Android 13: Work virtualization support (not the point, I won’t go into more detail here), but did you know you can run Linux on Android and, importantly, root is not required? Next we will introduce this 10,000 Star artifact — Termux.

What is Termux?

Termux is an open source Linux terminal simulator based on Android platform. It uses PKG (APT) to manage software packages. Best of all, it doesn’t require root privileges, so most Android will work. Termux website link

What can Termux do?

For now, it can do some simple Linux tasks:

  • Enjoy Bash and Zsh
  • Edit files using Vim
  • Access the server over SSH
  • Compile code using GCC and Clang
  • Use Git to examine projects
  • Run MySQL, Redis and other servers
  • .

Method of use

Because Termux is a Linux terminal emulator, the use of commands is consistent with Linux. Here, I’ll show you some ways to use the Termux tool.

For the first time to use

There is a consensus in the industry that when it comes to package management, official sources should be replaced with domestic mirror sources, and Termux is no exception. After entering Termux for the first time, we can use TUNA’s Termux image:

$ sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux stable main@' $PREFIX/etc/apt/sources. The list # # change the source file $PKG up update source file $PKG udpate - y && pkge upgrade # update the system and softwareCopy the code

After replacing it with a domestic mirror, you need to enable Termux storage permission:

$ termux-setup-storage
Copy the code

After the command is executed, a permission confirmation window is displayed. Select Always Allow.

PKG uses command shorthand

  • PKG Search Search package
  • PKG install Installation package
  • PKG uninstall Uninstall package
  • PKG update Update source
  • PKG Upgrade Upgrade package
  • PKG shoe displays the details of a package

Long press the screen

If you need to copy and paste content from Termux to Termux, you can do this by holding down the screen.

Extra button view

Above the normal keyboard, you can see a tray of additional function keys: ESC, Tab, CTRL, ALT, -, down and Up. With this extra line of views, it’s much easier to do things that aren’t on Android keyboards, but aren’t on computer keyboards.

Volume + combination

Because the Android keyboard does not have some function keys on the computer keyboard, we can hold down the volume key + and then enter an alphanumeric key on the keyboard to achieve some function keys.

  • Volume + Q: Show/hide additional key view
  • Volume + number key: Fx (number function key on computer keyboard)
  • The volume + L: | (pipe character)
  • Volume +H: ~ (wave character)
  • Volume +U: _ (underscore character)
  • Volume +P: previous page
  • Volume +N: Next page

Some simple applications

HTTP Server

Sometimes, we need to send some files from Android to other devices (such as laptops, sharing). The previous solution is generally to use wechat or QQ as a transfer station, now, you can use Termux to build a simple file server to achieve.

$PKG install python -y # $PKG install python -y # $PKG install python -y # $PKG install python -y # $PKG install python -y # $PKG install python -y # $PKG install python -y # HTTP. Server Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/)...Copy the code

After the command runs successfully, you can see that the output contains the port address (8000 in my case). In this case, use another device on the same LAN (such as Wi-Fi) to enter 192.168.2.104:8000 in the browser address to access the file server.

Looks like a hacker

When it comes to the command line, it’s hard not to get those cool characters raining down on you, which is just hacky. We can achieve this effect by installing PKG install cmartix.

Stern said

Generally speaking, the practicability is relatively poor, the operation is slightly tedious, but B Gran, can inadvertently in the program yuan in front of the show on such a hand, to ensure that the harvest sister full worship eyes, hairline seems to have moved forward a few XD

Pay attention to me, every day to bring a variety of SAO operation, practical skills, technical knowledge package you marry Bai Fumei, onto the peak of life.