Sudo Script for Termux (Root) - Android Software/Hacking General [Developers Only]
As a Linux user I use the sudo command very much to access the root file system of my desktop.But in Android when I started using Termux I found out that it has a beautiful Linux interface .But there was some problems in accessing some commands and changing owners or groups through the termux so I have made a simple script to make a sudo command.This command needs the su binary to be installed in your device for the command script to work.I also have made a permission fix script for termux.
Installation:
Extract the given zip.
Then copy the setperm script and sudo to the following location
/data/data/com.termux/files/usr/bin
Set permission 755 rwxr-xr-x
To both the files.
Changelog :
Full Magisk Support.
Now no problems using and other type of rooting methods.
Debugged error in script.
Any bugs found could be reported with the last log of the session by taking a screenshot of the session and attaching the png file.
Otherwise the bugs will be hard to fix.
Thank you for your cooperation.
the script was written by @st42
thanks to st42.
https://gitlab.com/st42/termux-sudo
How to install su binary? Can you provide some detail as I am a newbie?
shyamtiwari93 said:
How to install su binary? Can you provide some detail as I am a newbie?
Click to expand...
Click to collapse
Please refer to the SuperSU thread by chainfire or the Magisk thread by topjohnwu.
Or you could just search how to root in Google through any browser or lynx.
Can you fix this?
I am rooted with latest magisk v16.0.plz help
sudo su
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22132 Aborted $SU -c "$MOUNT_RW"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22136 Aborted $SU -c "mkdir $ROOT_HOME"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22140 Aborted $SU -c "chmod 700 $ROOT_HOME"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22147 Aborted $SU -c "echo -e $BASHRC > $ROOT_HOME/.bashrc"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22152 Aborted $SU -c "chmod 700 $ROOT_HOME/.bashrc"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22156 Aborted $SU -c "$MOUNT_RO"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 87: 22169 Aborted $SU -c "$CMDLINE"
munny_sun said:
Can you fix this?
I am rooted with latest magisk v16.0.plz help
sudo su
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22132 Aborted $SU -c "$MOUNT_RW"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22136 Aborted $SU -c "mkdir $ROOT_HOME"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22140 Aborted $SU -c "chmod 700 $ROOT_HOME"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22147 Aborted $SU -c "echo -e $BASHRC > $ROOT_HOME/.bashrc"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22152 Aborted $SU -c "chmod 700 $ROOT_HOME/.bashrc"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 65: 22156 Aborted $SU -c "$MOUNT_RO"
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
CANNOT LINK EXECUTABLE "/sbin/su": cannot locate symbol "XzUnpacker_Construct" referenced by "/system/lib64/libunwind.so"...
/data/data/com.termux/files/usr/bin/sudo: line 87: 22169 Aborted $SU -c "$CMDLINE"
Click to expand...
Click to collapse
Sorry support for Magisk is disabled.Support for Magisk will be brought in future.
Agni Datta said:
Sorry support for Magisk is disabled.Support for Magisk will be brought in future.
Click to expand...
Click to collapse
Anyway after some reading in GitHub commits
Changing SU=su worked for me!
Sent from my [device_name] using XDA-Developers Legacy app
Anyone know how to install fdisk ?
Murphy4432 said:
How to install it.
Click to expand...
Click to collapse
Download the zip, extract it, and follow the instructions in README.md
Sent from my OnePlus3T using XDA Labs
Agni Datta said:
Please refer to the SuperSU thread by chainfire or the Magisk thread by topjohnwu.
Or you could just search how to root in Google through any browser or lynx.
Click to expand...
Click to collapse
So for this to work. I need to have a rooted device?
munny_sun said:
Anyway after some reading in GitHub commits
Changing SU=su worked for me!
Sent from my [device_name] using XDA-Developers Legacy app
Click to expand...
Click to collapse
can you please elaborate
Anas Rahman said:
can you please elaborate
Click to expand...
Click to collapse
I am not using termux anymore but I think in the sudo file I changed these values to SU=su and it worked for magisk
if [ -x $SYSXBIN/su ]; then
SU=$SYSXBIN/su
elif [ -x /su/bin/su ]; then
SU=/su/bin/su
elif [ -x /sbin/su ]; then
SU=/sbin/su
Sent from my [device_name] using XDA-Developers Legacy app
munny_sun said:
I am not using termux anymore but I think in the sudo file I changed these values to SU=su and it worked for magisk
if [ -x $SYSXBIN/su ]; then
SU=$SYSXBIN/su
elif [ -x /su/bin/su ]; then
SU=/su/bin/su
elif [ -x /sbin/su ]; then
SU=/sbin/su
Click to expand...
Click to collapse
Sorry but I am a noob and don't know much, I can't understand what to do with the sudo file present in. ../termux-root
Anas Rahman said:
Sorry but I am a noob and don't know much, I can't understand what to do with the sudo file present in. ../termux-root
Click to expand...
Click to collapse
Just follow this procedure in the first post zip is given
Installation:
Extract the given zip.
Then copy the setperm script and sudo to the following location
/data/data/com.termux/files/usr/bin
Set permission 755 rwxr-xr-x
Then just open sudo file and change the values I mentioned it should work
Sent from my [device_name] using XDA-Developers Legacy app
munny_sun said:
Just follow this procedure in the first post zip is given
Installation:
Extract the given zip.
Then copy the setperm script and sudo to the following location
/data/data/com.termux/files/usr/bin
Set permission 755 rwxr-xr-x
Then just open sudo file and change the values I mentioned it should work
Sent from my [device_name] using XDA-Developers Legacy app
Click to expand...
Click to collapse
Magisk Support is back.
here is no problem in magisk su.
Fully supporting magisk.
Agni Datta said:
Magisk Support is back.
here is no problem in magisk su.
Fully supporting magisk.
Click to expand...
Click to collapse
Hey I need ur help it was working fine in custom rom but now in stock ROM its showing this error:-
$ sudo
bash: /data/data/com.termux/files/usr/bin/sudo: Permission denied
$ setperm.sh
bash: /data/data/com.termux/files/usr/bin/setperm.sh: Permission denied
Even though both files permission are set to 755
(rwx r-x r-x)
Sent from my [OnePlus 3] using XDA-Developers Legacy app
munny_sun said:
Hey I need ur help it was working fine in custom rom but now in stock ROM its showing this error:-
$ sudo
bash: /data/data/com.termux/files/usr/bin/sudo: Permission denied
$ setperm.sh
bash: /data/data/com.termux/files/usr/bin/setperm.sh: Permission denied
Even though both files permission are set to 755
(rwx r-x r-x)
Click to expand...
Click to collapse
I find that that I need to run restorecon on files that I've copied from my internal storage to /data otherwise I get permission problems.
Sent from my OnePlus3T using XDA Labs
BillGoss said:
I find that that I need to run restorecon on files that I've copied from my internal storage to /data otherwise I get permission problems.
Sent from my OnePlus3T using XDA Labs
Click to expand...
Click to collapse
Thanks man , it worked!
Sent from my [device_name] using XDA-Developers Legacy app
Thanks a lot for sharing. I think you quite mistyped in sudo's script, cos on Android permission 700 is not possible to apply I think. So all occurences must be changed to 755 am I right?.
Related
Running scripts directily (without write "sh" before)
Hi, I have a problem executing one script. I put my script as /system/bin/toleinit with 775 permissions: Code: # ls -l /system/bin/toleinit ls -l /system/bin/toleinit -rwxrwxr-x root root 373 2010-03-22 02:17 toleinit Well, when I try to run this script I get a "not found" error: Code: # /system/bin/toleinit /system/bin/toleinit /system/bin/toleinit: not found If I run it with "sh" the script works fine: Code: # sh /system/bin/toleinit sh /system/bin/toleinit +++ Wellcome to toleinit Script How to run the script directly? (without write "sh" before) The same error occurs when I run "busybox run-parts dirname", I get a "not found" error for each script file in the directory. Thanks in advance.
write this on the very first line of your script : #!/bin/sh Click to expand... Click to collapse
The first line is: Code: #!/system/bin/sh I think that is correct. or not?
Argh!! The problem is solved when I save the script file in UTF-8 and not ANSI. Now I can run the script without problems. Thanks anyway.
[Q]Installing busybox
Hi, I'm trying to install busybox into a development board by downloading the pre-compiled binary and following the installation steps here. However, after doing so, I'm still unable to use the commands in /system/busybox. For example, when I try to run mknod, it shows me the following error: Code: ./sh: mknod: not found Basically, I did the following: In Linux Code: adb root adb remount adb push busybox /system/busybox adb shell In device adb shell Code: cd /system/busybox ./busybox --install . ./sh cd /system/bin mv sh sh.android ln -s /system/busybox/sh sh It would seem like what I did to install busybox didn't work. May I know what's the correct procedure to install it? I tried creating symlinks using the same ln command and it works, but do I have to do this manually for every single command? Thanks!
goister said: Hi, I'm trying to install busybox into a development board by downloading the pre-compiled binary and following the installation steps here. However, after doing so, I'm still unable to use the commands in /system/busybox. For example, when I try to run mknod, it shows me the following error: Code: ./sh: mknod: not found Basically, I did the following: In Linux Code: adb root adb remount adb push busybox /system/busybox adb shell In device adb shell Code: cd /system/busybox ./busybox --install . ./sh cd /system/bin mv sh sh.android ln -s /system/busybox/sh sh It would seem like what I did to install busybox didn't work. May I know what's the correct procedure to install it? I tried creating symlinks using the same ln command and it works, but do I have to do this manually for every single command? Thanks! Click to expand... Click to collapse You didn't add /system/busybox to your PATH Sent from my LT26i using XDA
Hi, Where would I add it? init.rc or something?
Anyone? Thanks!
[WORKAROUND] Workaround for syntax errors in repo
soundemonchan said: For those getting a syntax error on Code: repo init It's because of Python3 being listed as Python in /usr/bin. A temporary workaround is to symlink python2 in place of python 3. Code: $ mkdir ~/bin $ ln -s /usr/bin/python2 ~/bin/python $ export PATH=~/bin:$PATH Check to see if it worked Code: $ which python And if it returns the binary in ~/bin/python it worked The solution would either be to symlink python by default or rewrite repo in Python3. Click to expand... Click to collapse Just thought I'd post this here in case someone needs it.
[ROOT/UNLOCK BOOTLOADER/RECOVERY]LG-D320/N/L70 devices
Quick guide for people having trouble rooting/unlocking bootloader and custom recovery LG-D320/N/L70 devices running 4.4.2 with a new 3.4.0+ kernel This way is easier then any root method and NO PC is required Simple, straight forward, takes not even 5 minutes. First download and install these 3 apps. CPU Benchamark Terminal Emulator KingoRoot.apk Second, download this zip file and extract the "mrw" folder to your phones internal memory(/sdcard) ReplaceKingoRoot.zip Third, open CPU Benchtest app and press the "stress test" box, then minimize the app and open Kingo ROOT app and press the "ROOT" bubble Fourth, Kingo ROOT says your device is rooted open Terminal Emulator and type the following Code: su Your device will ask if Terminal Emulator can be granted root permissions, allow it then proceed to type the following Code: sh /sdcard/mrw/root.sh Then SuperSU will automatically open and ask to update SuperSU binaries, select the "update" box and when it asks you how you want to update it select the "normal" box Five, Restart your phone when SuperSU says you need to restart for the update to take effect Now, unlocking the bootloader and flashing a custom recovery, fortunately i made a tool for this with the required files. simply download this, unzip it onto the desktop and run LGTOOL.BAT by double clicking it and follow the instructions. LG TOOL BY RICKY DIVJAKOVSKI ENJOY GUYS Credits: jeffta74 wanako1 MrW0lf
updated.
I'm AndroidAddict aka MikeHoncho at AF btw. Glad to see someone post something even though we never got a forum here
AndroidAddict||AA said: I'm AndroidAddict aka MikeHoncho at AF btw. Glad to see someone post something even though we never got a forum here Click to expand... Click to collapse every device should be able to gain full flexibillity, no matter how old, how new, how popular or unpopular and device i get my hands on will gain full access time to make a custom rom now
I think everything is done "custom ROM" wise. AOSP, cm11, cm12, carbon (by me) and other ROMs
AndroidAddict||AA said: I think everything is done "custom ROM" wise. AOSP, cm11, cm12, carbon (by me) and other ROMs Click to expand... Click to collapse ofcoarse its done custom rom wise, you can modify a rom with root access but to safely modify a rom and test recovery is mandatory
Terminal emulator not working Thx for this guide. terminal emulator can't install SuperSU. Here's the log, whats wrong? Tried also to install supersu manually, but can't update it so is absolutely useless. [email protected]:/ $ su l_SD/ReplaceKingoRoot/mrw/root.sh < --------------------------------------- ---------- Made By : Mr.W0lf ---------- ---- Thanks @Chainfire for SuperSU ---- --------------------------------------- --------------------------------------- ----- UPDATED BY RICKY DIVJAKOVSKI ---- --------------------------------------- Failure Failure rm failed for /system/app/KingoUser, No such file or directory /storage/external_SD/ReplaceKingoRoot/mrw/root.sh[20]: cat: sdcard/mrw/busybox: No such file or directory rm failed for /system/xbin/ku.sud, No such file or directory rm failed for /system/xbin/su, Operation not permitted /storage/external_SD/ReplaceKingoRoot/mrw/root.sh[33]: can't create /system/xbin/su: Permission denied /storage/external_SD/ReplaceKingoRoot/mrw/root.sh[34]: can't create /system/xbin/daemonsu: Text file busy /storage/external_SD/ReplaceKingoRoot/mrw/root.sh[35]: cat: /sdcard/mrw/su: No such file or directory Unable to chown /system/xbin/su: Operation not permitted Unable to chmod /system/xbin/su: Operation not permitted daemonsu: invalid option -- d Usage: su [options] [--] [-] [LOGIN] [--] [args...] Options: --daemon start the su daemon agent -c, --command COMMAND pass COMMAND to the invoked shell -h, --help display this help message and exit -, -l, --login pretend the shell to be a login shell -m, -p, --preserve-environment do not change environment variables -s, --shell SHELL use SHELL instead of the default /system/bin/sh -u display the multiuser mode and exit -v, --version display version number and exit -V display version code and exit, this is used almost exclusively by Superuser.apk rm failed for /data/data-lib/com.kingoapp.root, No such file or directory rm failed for /data/data-lib/com.kingouser.com, No such file or directory rm failed for /data/data/com.kingroot.RushRoot, No such file or directory rm failed for /data/data-lib/com.kingroot.RushRoot, No such file or directory rm failed for /data/data/com.kingroot.kinguser, No such file or directory rm failed for /data/data-lib/com.kingroot.kinguser, No such file or directory rm failed for /data/data/com.kingroot.master, No such file or directory rm failed for /system/bin/.usr/.ku, No such file or directory rm failed for /system/bin/rt.sh, No such file or directory rm failed for /system/bin/su, Operation not permittedrm failed for /system/bin/ddexe, No such file or directory rm failed for /system/bin/install-recovery.sh, No such file or directory rm failed for /system/bin/install-recovery.sh-ku.bak, No such file or directory pkg: /sdcard/mrw/superuser.apk Failure [INSTALL_FAILED_INVALID_URI] rm failed for /system/usr/iku, No such file or directory rm failed for /dev/reportroot, No such file or directory rm failed for /system/app/Kinguser, No such file or directory rm failed for /data/data-lib/king, No such file or directory rm failed for /sdcard/Kingroot, No such file or directory Error type 3 Error: Activity class {eu.chainfire.supersu/eu.chainfire.supersu.MainActivity} does not exist. [email protected]:/ #ll
Ggcost said: Thx for this guide. terminal emulator can't install SuperSU. Here's the log, whats wrong? Tried also to install supersu manually, but can't update it so is absolutely useless. [email protected]:/ $ su l_SD/ReplaceKingoRoot/mrw/root.sh < --------------------------------------- ---------- Made By : Mr.W0lf ---------- ---- Thanks @Chainfire for SuperSU ---- --------------------------------------- --------------------------------------- ----- UPDATED BY RICKY DIVJAKOVSKI ---- --------------------------------------- Failure Failure rm failed for /system/app/KingoUser, No such file or directory /storage/external_SD/ReplaceKingoRoot/mrw/root.sh[20]: cat: sdcard/mrw/busybox: No such file or directory rm failed for /system/xbin/ku.sud, No such file or directory rm failed for /system/xbin/su, Operation not permitted /storage/external_SD/ReplaceKingoRoot/mrw/root.sh[33]: can't create /system/xbin/su: Permission denied /storage/external_SD/ReplaceKingoRoot/mrw/root.sh[34]: can't create /system/xbin/daemonsu: Text file busy /storage/external_SD/ReplaceKingoRoot/mrw/root.sh[35]: cat: /sdcard/mrw/su: No such file or directory Unable to chown /system/xbin/su: Operation not permitted Unable to chmod /system/xbin/su: Operation not permitted daemonsu: invalid option -- d Usage: su [options] [--] [-] [LOGIN] [--] [args...] Options: --daemon start the su daemon agent -c, --command COMMAND pass COMMAND to the invoked shell -h, --help display this help message and exit -, -l, --login pretend the shell to be a login shell -m, -p, --preserve-environment do not change environment variables -s, --shell SHELL use SHELL instead of the default /system/bin/sh -u display the multiuser mode and exit -v, --version display version number and exit -V display version code and exit, this is used almost exclusively by Superuser.apk rm failed for /data/data-lib/com.kingoapp.root, No such file or directory rm failed for /data/data-lib/com.kingouser.com, No such file or directory rm failed for /data/data/com.kingroot.RushRoot, No such file or directory rm failed for /data/data-lib/com.kingroot.RushRoot, No such file or directory rm failed for /data/data/com.kingroot.kinguser, No such file or directory rm failed for /data/data-lib/com.kingroot.kinguser, No such file or directory rm failed for /data/data/com.kingroot.master, No such file or directory rm failed for /system/bin/.usr/.ku, No such file or directory rm failed for /system/bin/rt.sh, No such file or directory rm failed for /system/bin/su, Operation not permittedrm failed for /system/bin/ddexe, No such file or directory rm failed for /system/bin/install-recovery.sh, No such file or directory rm failed for /system/bin/install-recovery.sh-ku.bak, No such file or directory pkg: /sdcard/mrw/superuser.apk Failure [INSTALL_FAILED_INVALID_URI] rm failed for /system/usr/iku, No such file or directory rm failed for /dev/reportroot, No such file or directory rm failed for /system/app/Kinguser, No such file or directory rm failed for /data/data-lib/king, No such file or directory rm failed for /sdcard/Kingroot, No such file or directory Error type 3 Error: Activity class {eu.chainfire.supersu/eu.chainfire.supersu.MainActivity} does not exist. [email protected]:/ #ll Click to expand... Click to collapse Yea i have the same problem with this i've done everything right step by step but seems cant find the location of the root can anyone help me or the topic is dead ?
Problem in running sh file
I m using Kali nethunter on kenzo . I m getting problem in running sh file (setup) Command ./setup.sh bash: ./setup.sh: Permission denied Command sudo ./setup.sh Sudo: ./setup.sh: command not found I have tried on vnc and chmod +x but nothing is working. I have also tried on xperia z but not working. I have tried installing veil avasion and fluxion and many other setup but all with same error..I