Tag Archives: su

Termux setting path environment variable

Problem description

When using termux, it is found that the permissions are not enough by using commands. After switching to root by using Su, it is found that many previous commands cannot be used

First, echo $path to view the environment variable of root

Results: in/SBIN/Su/Su/bin/Su/xbin/system/bin/system/xbin

It is found that these three are all in the root path, without/data/data/com.termux/files/usr/bin, so the command here can’t be executed naturally

Exit switch to normal user.

Echo $path view environment variables

The value is/data/data/com. Termux/files/usr/bin/data/data/com. Termux/files/usr/bin/applets

That is to say, you just need to tell root the variables of ordinary users

Here is the solution——————————————————————————————-

In order to ensure the security of the system, the temporary variable is used to save the error

export PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:$PATH

(tell root the executable

Note that there is no space beside the equal sign, the colon in English: segmentation, the front part is the path value of ordinary users: the Lib path of ordinary users (because some commands also need the library files we download), just paste it

export LD_ LIBRARY_ PATH=/data/data/com.termux/files/usr/lib

(link LIB)

be careful!! For the sake of safety, the operation I posted is temporary. Exit will restore the original identity or turn it off or reopen it. But it’s absolutely safe.

For your convenience, you can create a script to quickly use the downloaded function.

Cd ~ (home directory)

VIM getmytermuxorders (create a file)

Enter the following:

#!/bin/bash
export PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:$PATH
export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib
echo "LYM_nb" 

: WQ save exit

Then exit returns to the original user

When you want to use the root permission again in the future:

Su or TSU comes to root

Run the source command directly in the home directory

source getMyTermuxOrders

If output lym_ NB means that all bin functions of termux have been obtained

You can also use export, echo $path, env and other commands to confirm