On LineageOS 23.2 with Magisk, you don’t have a traditional /etc/sudoers file (since Android is not a full Unix system), but you can achieve similar functionality for running specific commands as root from Termux using the following approaches:
sudo in TermuxTermux can install a sudo package, which allows you to run commands as root if you have Magisk installed (which provides root access).
Install sudo in Termux:
bashpkg install tsu
tsu is a Termux-specific sudo alternative.
Add a Rule for Specific Commands:
sudoers file for Termux (located at /data/data/com.termux/files/usr/etc/sudoers).u0_a123) to run a specific command as root:
textu0_a123 ALL=(root) NOPASSWD: /path/to/your/command
u0_a123 with your Termux app’s user ID (find it with id in Termux).Set Permissions:
bashchmod 440 /data/data/com.termux/files/usr/etc/sudoers chown root:root /data/data/com.termux/files/usr/etc/sudoers
Usage:
bashsudo /path/to/your/command
su DirectlyIf you want to allow Termux to run su without a password for specific commands, you can use Magisk’s built-in su rules.
Edit Magisk’s su Rules:
textsu
Allow Termux to Use su:
bashsu -c "your_command"
termux-setup-storage and termux-chrootIf you need to run commands in a more controlled environment, you can use Termux’s chroot or bind mounts.
sudosudoers file.sudo /system/bin/rebootsu Rulessu -c "mount -o remount,rw /"chroottermux-chroot ls /Which method do you want to use? If you need help setting up a specific rule or troubleshooting, let me know!