How to run adb and fastboot commands from Termux? Is it possible to run adb and fastboot commands using Termux terminal emulator? I am wanting to run commands from one Huawei T3 7 to another using USB/OTG cable. Need to unlock bootloader but have no access to a PC or laptop.
This question is nearly a duplicate of this which has a detailed answer by @Firelord, except the Termux part. As mention by @DeathMaskSalesman in comment, Termux is more like a Linux environment, but so far it doesn't have adb and fastboot in repositories, though proposed. Most probably because they are meant for rooted devices. But you can use static binaries (e.g. this or this) on Termux like on usual Terminal emulator app. Make sure to set proper environment variables (TMPDIR, HOME or HOMEDIR).
However you won't be able to run each of them without root because only members of AID_USB group are able to read devices in /dev/bus/usb/ (1). Furthermore SELinux restricts unprivileged apps' access to /sys and /dev.
For adb there's a workaround if both devices are connected to same network e.g. Wi-Fi or hotspot. adbd can be run to listen on TCP socket instead of USB. It's possible if before turning on &quot;USB Debugging&quot; property service.adb.tcp.port (2) is set to some port (first default is 5555). Apps can't set properties, so to do this using setprop on adb shell or by simply executing adb tcpip 5555, you need to connect the target device to a PC over USB. Then all you have to do from Termux before sending commands is:
~$ adb connect &lt;IP&gt;:5555

But service.adb.tcp.port is reset on reboots and you have to set it again. There is another property persist.adb.tcp.port which persists across reboots but it's meant only for testing and SELinux won't let you set this without root or some system app running with UID 1000.
Some custom ROMs have built-in toggle to set service.adb.tcp.port. But for fastboot root is must. However it's possible on Android to access USB OTG devices through android.hardware.usb APIs. fastboot-mobile is an unofficial library from Google to send fastboot commands over OTG. This app (I have no affiliation) also provides similar limited functionality.