Best run shell commands in Tasker

Search This thread

quintaar

Senior Member
Jan 7, 2009
76
37
Teeside
Hello guys.

I stumbled across a reddit thread providing some run shell commands to replace secure settings. The fixes on Android 6.0 allowed me to install and grand the root permissions but never actually worked as intended. Secure settings still returns errors when used.

Long story short I built on the list adding ones I used before from my list.

Here is about 30 most common run shell commands. I will update list if i come across some new ones. Also appreciate your input if you happen to use some good ones.

You can access it all here:
http://www.notenoughtech.com/tasker/tasker-run-shell-commands/
Happy tasking. :good:
 

Sukarn

Senior Member
Apr 24, 2011
310
323
Boy, where do I start? The list would be endless. Anyway, here are some, not all, that I use.

Root commands
Open power menu: sendevent /dev/input/event0 1 116 108 && sendevent /dev/input/event0 0 0 0

Restart SystemUI: pkill -l TERM -f com.android.systemui

Safe reboot: svc power reboot

Safe reboot to recovery: svc power reboot recovery

Get list of all system/global/secure settings along with their values; using system settings as example: settings list system

Read system/global/secure setting to a variable; using secure setting accessibility_enabled as example: settings get secure accessibility_enabled

Change system/global/secure setting; using secure setting accessibility_enabled as example: settings put secure accessibility_enabled 0

Make /system rewritable: mount -o remount,rw /system

Make /system read-only: mount -o remount,ro /system

Change file permissions, using /system/etc/hosts as example; numbers are 7 for rwx, 6 for rw, 4 for r; first number is for root (system user), second is for group, third is for all users: chmod 644 /system/etc/hosts

Tap at x,y pixels on screen, using 540,1500 as example: input tap 540 1500

Swipe from x1,y1 to x2,y2, using 540,1500 to 540,300 (swipe up) as example: input swipe 540 1500 540 300

Read/change another app's database; can't give examples as this would need a full tutorial: sqlite3 /path/to/.db_file "sqlite3 commands";

non-root command
Open any app from a variable %package_name containing com.paclage.name; this one is javascript, not shell script [note that you don't want to put % before variable in javascript]: loadApp(package_name, '', false);

Extract %file zip file to /sdcard: unzip %file /sdcard/

Move a file: mv /original/path /new/path

Copy a file: cp /original/path /new/path

Read a file to a variable: cat /path/to/file

Write %var to a file: echo %var > /path/to/file

Delete a file: rm /path/to/file

Delete a folder and all its contents: rm -r /path/to/folder

Check whether a process is doing something or not; set the output to a variable, set a wait for some time, and then get the output again, if output has changed then the process is doing something: ps | grep com.package.name
 
Last edited:

LeftyGR

Senior Member
Oct 18, 2011
2,120
1,712
Bloomington, IL
Is input keyevent correct for emulating the power button in a shell command? The # on the website didn't work. I found the generic.kl file in my /system/usr folders and the key # for power listed there did now work with that shell command, either. Even with run as root checked.
2a4d0e78a6937d32467a80f0979eb304.jpg
 

quintaar

Senior Member
Jan 7, 2009
76
37
Teeside
Is input keyevent correct for emulating the power button in a shell command? The # on the website didn't work. I found the generic.kl file in my /system/usr folders and the key # for power listed there did now work with that shell command, either. Even with run as root checked.
I believe hardware keys would be device specific, ego could have different codes.
 

quintaar

Senior Member
Jan 7, 2009
76
37
Teeside
Are you trying to do this when the phone display is on or off? this only works when screen is on. input keyevent 26 works fine on my device
 

Sukarn

Senior Member
Apr 24, 2011
310
323
I totally forgot about another shell command that I have set up in Tasker: md5sum /path/to/file

I use it to verify the integrity of downloads in an OTA app I made for a custom ROM using only Tasker.

---------- Post added at 10:52 AM ---------- Previous post was at 10:43 AM ----------

Are you trying to do this when the phone display is on or off? this only works when screen is on. input keyevent 26 works fine on my device
On my phone (OnePlus One), "input keyevent 26" just turns the screen off, while 116 does nothing.
I guess my real question is that the correct shell command as it is written? Because with my specific device key code did not do anything.
Did you try the command I posted at the top of my post here? It's the second post in this thread.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 22
    Hello guys.

    I stumbled across a reddit thread providing some run shell commands to replace secure settings. The fixes on Android 6.0 allowed me to install and grand the root permissions but never actually worked as intended. Secure settings still returns errors when used.

    Long story short I built on the list adding ones I used before from my list.

    Here is about 30 most common run shell commands. I will update list if i come across some new ones. Also appreciate your input if you happen to use some good ones.

    You can access it all here:
    http://www.notenoughtech.com/tasker/tasker-run-shell-commands/
    Happy tasking. :good:
    7
    Boy, where do I start? The list would be endless. Anyway, here are some, not all, that I use.

    Root commands
    Open power menu: sendevent /dev/input/event0 1 116 108 && sendevent /dev/input/event0 0 0 0

    Restart SystemUI: pkill -l TERM -f com.android.systemui

    Safe reboot: svc power reboot

    Safe reboot to recovery: svc power reboot recovery

    Get list of all system/global/secure settings along with their values; using system settings as example: settings list system

    Read system/global/secure setting to a variable; using secure setting accessibility_enabled as example: settings get secure accessibility_enabled

    Change system/global/secure setting; using secure setting accessibility_enabled as example: settings put secure accessibility_enabled 0

    Make /system rewritable: mount -o remount,rw /system

    Make /system read-only: mount -o remount,ro /system

    Change file permissions, using /system/etc/hosts as example; numbers are 7 for rwx, 6 for rw, 4 for r; first number is for root (system user), second is for group, third is for all users: chmod 644 /system/etc/hosts

    Tap at x,y pixels on screen, using 540,1500 as example: input tap 540 1500

    Swipe from x1,y1 to x2,y2, using 540,1500 to 540,300 (swipe up) as example: input swipe 540 1500 540 300

    Read/change another app's database; can't give examples as this would need a full tutorial: sqlite3 /path/to/.db_file "sqlite3 commands";

    non-root command
    Open any app from a variable %package_name containing com.paclage.name; this one is javascript, not shell script [note that you don't want to put % before variable in javascript]: loadApp(package_name, '', false);

    Extract %file zip file to /sdcard: unzip %file /sdcard/

    Move a file: mv /original/path /new/path

    Copy a file: cp /original/path /new/path

    Read a file to a variable: cat /path/to/file

    Write %var to a file: echo %var > /path/to/file

    Delete a file: rm /path/to/file

    Delete a folder and all its contents: rm -r /path/to/folder

    Check whether a process is doing something or not; set the output to a variable, set a wait for some time, and then get the output again, if output has changed then the process is doing something: ps | grep com.package.name
    3
    This is awesome. Do you mind sharing a screenshot of it and also tell me how you've done the OTA app?
    Screenshots (somewhat outdated and don't contain all current features): https://goo.gl/photos/1LwRquHioBVveS1h8

    App and tasker project, i.e. source code (needs both apk files to be installed): https://drive.google.com/folderview?id=0B4q2Ez1yS1rKNVBIQU9KQmQtWEU

    Feature list: http://forum.xda-developers.com/showthread.php?p=67829941
    2
    d150219dbfa43612f01c0689ea51c63e.jpg
    1a5d5e5f05207ae18989f164863ec77a.jpg


    Are you sure? Works like a charm. Remember to turn on the wifi after the airplane mode is done.

    Sent from my Nexus 6P using Tapatalk
    Yeah mate. My network wifi is 'special' and only appears if sim can be detected (so airplane mode needs to be off)


    Buuut, I managed to get it. Using secure settings plugin I can select what to turn off with airplane mode :)

    Sent from my Nexus 5X using Tapatalk
    1
    @ontwykende, try importing these two tasks. They are named "data on 2" and "data off 2" so when you import them they won't overwrite the existing tasks.