Unlike using Fastboot from a PC (which abstracts partition names), unlocking from within the OS requires specific knowledge of your device's partition layout.

This guide assumes your device has a specific exploit or root access already established. Standard, locked consumer devices (like a standard Samsung or Pixel) cannot unlock the bootloader solely through Termux without an existing root exploit or a computer, as the fastboot oem unlock command requires a trusted connection from the bootloader state, not the Android OS.

pkg install tsu tsu fastboot devices

Before attempting an unlock through Termux, you must ensure the target device is prepared: Developer Options

adb kill-server adb start-server adb devices