AndronixApp / AndronixOrigin

This is the official repository for the back end of the Andronix app 🚀. Here you can know all the scripts you're installing 😎
https://andronix.app
MIT License
1.74k stars 334 forks source link

Not an issue, but an idea to run the Linux as a USER, not as ROOT by default #145

Open freebrowser1 opened 2 years ago

freebrowser1 commented 2 years ago

When Andronix installs a Linux distro, it runs flawlessly, but it is run as root (i.e. not the actual Android root as it runs on non-rooted devices, but the 'fake root' of the proot application. Despite some apps (e.g. Freetube) won't run at all or at leasy you are running it as root.

Here a tip to run Linux apps as a user rather than root. Run ~/start-ubuntu.sh from Termux. Then a new 'root' shell is started and run:

adduser myuser

Add a line to /etc/sudoers :

myuser ALL=(root) NOPASSWD: ALL

and run chmod -R 0440 /etc/sudoers* Otherwise sudo won't work if you are within the Linux distribution and run sudo when really needing 'root' commands.

*startubuntu.sh:

#!/data/data/com.termux/files/usr/bin/bash
~/start-ubuntu.sh vncserver-stop
pkill ssh-agent* && pkill gpg-agent*
# When running Android 12 or higher (and you are rooted with *real* android root), set the max number of processes over 32:
    sudo /system/bin/device_config put activity_manager max_phantom_processes 2147483647
    # turn off SELinux of Android
    sudo setenforce 0
##
pulseaudio --start
~/start-ubuntu.sh vncuser &

These can be put in .shortcuts/Andronix which allows them to be shown in Termux widget so can be started from a widget on Android rather than as a command.

The extra command 'vncuser' should be put into the folder /usr/local/bin (e.g. ~/ubuntu20-fs/usr/local/bin in Termux in the case of Ubuntu 20) in the distro folder, where vncserver-start and vncserver-stop reside. It contains:

#!/usr/bin/env bash

export USER=myuser
export HOME=/home/myuser

 su -c 'HOME=$HOME && cd $HOME && vncserver -name remote-desktop -geometry 1280x720 -localhost no :1' $USER
#original command: 
# vncserver -name remote-desktop -geometry 1280x720 -localhost no :1

Tested succesfully under Android 10 on One+ 6 and under Android 12 (API 31) on Android Studio ARM version (Mac M1). Both are rooted, but that is only needed for the two extra commands for disabling SELinux and turning off the maximum process limit which is optional.

Have fun !

dontknowhy commented 2 years ago

you can just replace the /bin/bash --login with /usr/bin/login

0pLuS0 commented 1 year ago

you can just replace the /bin/bash --login with /usr/bin/login

Then you have to run sudo unminimize and re do the system pkgs over as a user. Now I wonder doing this, how much might break... hmm

I don't understand why Linux distros under Andronix aren't being run as a user, the normal desktop Linux way, instead of root?

Hmm ;/

Fede2782 commented 9 months ago

They reserve this feature to premium users with modded os