Skip to content

Instantly share code, notes, and snippets.

@leolovenet
Last active December 6, 2023 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leolovenet/a92abc1eec463e11bac3dde2cfe5e314 to your computer and use it in GitHub Desktop.
Save leolovenet/a92abc1eec463e11bac3dde2cfe5e314 to your computer and use it in GitHub Desktop.
revsu
#!/system/bin/sh
# https://github.com/topjohnwu/Magisk/blob/master/native/src/core/su/su_daemon.cpp
# https://android.stackexchange.com/a/217104/400354
UID=$(grep com.termux /data/system/packages.list | awk '{print $2}')
############################################################################################################
# This command needs to be edited manually before use,
# you need to execute the command `/system/bin/id` in Termux as a normal user to get the corresponding group id number,
# replacing the following ID numbers obtained on my phone
############################################################################################################
/system/bin/su \
--group $UID \
--supp-group 3003 \
--supp-group 9997 \
--supp-group 20266 \
--supp-group 50266 \
--supp-group 99909997 \
$UID \
-c 'PATH=/system/bin:/system/xbin env -i \
ANDROID_ART_ROOT=/apex/com.android.art \
ANDROID_DATA=/data \
ANDROID_I18N_ROOT=/apex/com.android.i18n \
ANDROID_ROOT=/system \
ANDROID_TZDATA_ROOT=/apex/com.android.tzdata \
EXTERNAL_STORAGE=/sdcard \
HISTCONTROL=ignoreboth \
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so \
PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin \
PREFIX=/data/data/com.termux/files/usr \
HOME=/data/data/com.termux/files/home \
PWD=/data/data/com.termux/files/home \
TMPDIR=/data/data/com.termux/files/usr/tmp \
TERM=xterm-256color \
/data/data/com.termux/files/usr/bin/fish'
@leolovenet
Copy link
Author

This is a reverse operation command similar to the tsu command under Termux, mainly used to return to the normal user under root, in order to facilitate the installation and update functions of the pkg command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment