meefik / linuxdeploy

Install and run GNU/Linux on Android
https://meefik.github.io/linuxdeploy
GNU General Public License v3.0
5.23k stars 680 forks source link

Execute Command from Android #862

Open nsatech opened 7 years ago

nsatech commented 7 years ago

When running "df" from android, the following shows up:

/dev/loop0 1511856 796924 638132 56% /data/local/mnt tmpfs 442544 140 442404 0% /data/local/mnt/dev tmpfs 442544 0 442544 0% /data/local/mnt/dev/shm tmpfs 442544 0 442544 0% /dev/shm tmpfs 442544 0 442544 0% /data/local/mnt/dev/shm tmpfs 442544 0 442544 0% /dev/shm


I'd like to know how I can execute commands to the linux container (/data/local/mnt) from Android.

From example, if I wanted to do an "apt install " from android as opposed to running: apt install , inside the linux container.

Your support on this matter would be appreciated. Thanks.

GrahamCobb commented 6 years ago

/data/data/ru.meefik.linuxdeploy/bin/linuxdeploy is very useful for this. Run it without any arguments for a list of commands.

/data/data/ru.meefik.linuxdeploy/bin/linuxdeploy shell starts a bash shell in the linux container.

If you want to run a script you can tell it to run that instead. For example: /data/data/ru.meefik.linuxdeploy/bin/linuxdeploy shell /usr/local/sbin/myscript

Note that /data/data/ru.meefik.linuxdeploy/bin/linuxdeploy shell /bin/bash -c apt upgrade does not work. It seems that linuxdeploy shell cannot handle multiple arguments to the command being invoked. But you can get round this by creating a script and running that instead.

meefik commented 6 years ago

Please try:

linuxdeploy shell "/bin/bash -c apt upgrade"