How to run Termux commands?

Post Reply
franek
Posts: 1
Joined: Tue Mar 10, 2026 5:36 pm

How to run Termux commands?

Post by franek »

I cannot figure out how to run a Termux command from Automation, and the configuration example [0] is a bit sparse. Can someone help? A detailed example would be most helpful, I think.

The first thing I am unsure about is if I should use the action type "Start another program" or "Run script or executable". With the first approach, it looks like the way to go would be to copy relevant bits of the Java code from the Termux wiki page on RUN_COMMAND [1] into Automation. With the second, to use an "am" command, again like in the wiki page.

I tried both, but couldn't get the action to do anything or the log to show anything helpful.

I have granted Automation the permission "Run commands in Termux environment".


[0]: https://server47.de/automation/examples.html
[1]: https://github.com/termux/termux-app/wi ... AND-Intent
jens
Posts: 15
Joined: Sat Oct 18, 2025 10:15 pm

Re: How to run Termux commands?

Post by jens »

I'm not using Termux myself, so I can't test this without setting up an environment.

This might work:

- Start another program
- by action (not by activity)
- by start service
- Package: com.termux
- Class com.termux.app.RunCommandService
- Action name com.termux.RUN_COMMAND
- String parameter:
* name: com.termux.RUN_COMMAND_PATH
* value: /data/data/com.termux/files/home/test.sh

From the documentation it also uses arrays as parameters which Automation does not support yet. I don't know how relevant those are for Termux's operation.
Ehud Kirsh
Posts: 1
Joined: Thu Mar 26, 2026 11:09 pm

Re: How to run Termux commands?

Post by Ehud Kirsh »

Dear franek and jens,

My name is Ehud and I'm a big fan of both apps: Termux and Automation.

I had this exact issue myself and solved it several days before franek posted. So I was going to publish a detailed GitHub repo on how to automate Termux anyway, but prioritised it since I saw the demand.

I published it here just now: https://github.com/EhudKirsh/Termux-Plu ... Automation

In a nutshell, I want to compliment jens for getting the Android Intents mostly correctly, but with some missing important steps:

- To get a script file to the /data/data/com.termux/files/home/ folder you need to know what File Manager apps to use to mount Termux using SAF OR what Termux commands to use to access this private folder of Termux.
- Most importantly: either the script file itself must be set to be executable OR the folder it's in must set all scripts inside it, present and future, to be executable. This must be done in Termux. It cannot be done with a File Manager or any other app.
- Equally most importantly: you must add the 'allow-external-apps=true' line to the ~/.termux/termux.properties file AND grant the 'Run commands in Termux environment' permission to the Automation app.
- To run a script silently in the background without opening a new Termux tab, it's important to add another 'Intent pair' named 'com.termux.RUN_COMMAND_BACKGROUND' with a 'boolean' type and a 'true' value.
jens
Posts: 15
Joined: Sat Oct 18, 2025 10:15 pm

Re: How to run Termux commands?

Post by jens »

Thank you! I appreciate the work you've put into this documentation.
Post Reply