Skip to content

Instantly share code, notes, and snippets.

@alvaro-jmp
Last active March 19, 2025 11:22
Show Gist options
  • Select an option

  • Save alvaro-jmp/fda0eb48527b932bf2663d29ebfdb366 to your computer and use it in GitHub Desktop.

Select an option

Save alvaro-jmp/fda0eb48527b932bf2663d29ebfdb366 to your computer and use it in GitHub Desktop.
Run adb shell as root and load the termux environment with zsh
#!/usr/bin/env expect
spawn adb shell
expect ":/"
send "/sbin/su -c PREFIX=/data/data/com.termux/files/usr LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so HOME=/data/data/com.termux/files/home/.suroot TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp ANDROID_DATA=/data TERM=xterm-256color ANDROID_ROOT=/system PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin TERMUX_FS=\"/data/data/com.termux/files\" TERMUX_PREFIX=\"\$TERMUX_FS/usr\" TERMUX_PATH=\"\$TERMUX_PREFIX/bin:\$TERMUX_PREFIX/bin/applets\" ROOT_HOME=\"\$TERMUX_FS/home/.suroot\" ANDROID_SYSPATHS=\"/system/bin:/system/xbin\" EXTRA_SYSPATHS=\"/sbin:/sbin/bin\" /data/data/com.termux/files/usr/bin/zsh"
send "\r"
expect "root@localhost"
send " cd"
send "\r"
send " clear"
send "\r"
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment