Following my recent write up on Secure Settings not playing well with Android 6.0 devices, I decided to make another post about the run shell option in Tasker. I think it is a good idea to keep all of them handy in one place instead of running around the web, looking for the information.  I have a small collection of these already in my notepad. I will be updating the list each time I come across something interesting. Watch this space then, perhaps subscribe to receive updates to this post. Perhaps, later on, I will create one for the intents as well. You can read more on intents here.

And if you have any great run shell commands, let me know in the comments, I will update the list as well.

Not all devices have been made equal and to find out what settings can be toggled on yours, you need to check what is available. There are 3 groups of settings: secure, global and system. To check status of the settings simply run one of:

settings list system
settings list global
settings list secure

Store result in a variable %Settings. You can also use Set Clipboard to %Settings, and use Join to bring it on your PC, or use Write file with %Settings to save it to a text file.  In the file, you will find the list of available settings to be toggled. These will have their current state already specified by the number at the end (0= disabled, 1=enabled).

There are 2 more commands I want you to learn.

settings get secure/global/system name_of_the_setting
settings put secure/global/system name_of_the_setting 0or1

  • GET allows you to get the current status of the setting
  • PUT allows you to set the setting to your desired value

This alone will let you compose about 100 Run Shell commands on your own! Something I have noticed, to see the setting being changed on your mobile, you will have to leave the equivalent menu and reenter it again, so changes made would reflect in the user interface. Simply putting the screen to the background and going back won’t work. I kept  few most popular toggles in the list as an example, and for an easy access.

[toggle title=”Example list of settings on Nexus 6p”]
[tabs]
[tab title=”settings list system”]
accelerometer_rotation=0
alarm_alert=content://media/internal/audio/media/11
alarm_alert_set=1
bd_setting_i=867981022506516
dim_screen=1
dtmf_tone=1
dtmf_tone_type=0
haptic_feedback_enabled=1
hearing_aid=0
hide_rotation_lock_toggle_for_accessibility=0
lockscreen_sounds_enabled=1
microphone_mute=0
mode_ringer_streams_affected=422
mute_streams_affected=46
next_alarm_formatted=
notification_light_pulse=0
notification_sound=content://media/internal/audio/media/24
notification_sound_set=1
pointer_speed=0
radio.data.stall.recovery.action=0
ringtone=content://media/internal/audio/media/36
ringtone_set=1
screen_brightness=216
screen_brightness_mode=0
screen_off_timeout=120000
sound_effects_enabled=1
status_bar_show_battery_percent=1
transition_animation_scale=1.0
tty_mode=0
user_rotation=0
vibrate_when_ringing=0
volume_alarm=6
volume_bluetooth_sco=7
volume_bluetooth_sco_earpiece=9
volume_music=11
volume_music_bt_a2dp=11
volume_music_headphone=4
volume_music_headset=4
volume_music_speaker=5
volume_notification=5
volume_ring=5
volume_ring_bt_a2dp=5
volume_ring_earpiece=5
volume_ring_speaker=1
volume_system=7
volume_voice=4
volume_voice_earpiece=4
window_animation_scale=1.0
[/tab]
[tab title=”settings list global”]
adb_enabled=1
airplane_mode_on=0
airplane_mode_radios=cell,bluetooth,wifi,nfc,wimax
airplane_mode_toggleable_radios=bluetooth,wifi,nfc
app_idle_constants=idle_duration=94610000000
assisted_gps_enabled=1
audio_safe_volume_state=3
auto_time=1
auto_time_zone=1
ble_scan_always_enabled=1
bluetooth_a2dp_sink_priority_00:18:6B:F3:AF:17=1000
bluetooth_disabled_profiles=0
bluetooth_headset_priority_00:18:6B:F3:AF:17=1000
bluetooth_on=1
bugreport_in_power_menu=0
call_auto_retry=0
captive_portal_detection_enabled=1
car_dock_sound=/system/media/audio/ui/Dock.ogg
car_undock_sound=/system/media/audio/ui/Undock.ogg
cdma_cell_broadcast_sms=1
cert_pin_content_url=https://www.gstatic.com/android/config_update/08202014-pins.txt
cert_pin_metadata_url=https://www.gstatic.com/android/config_update/08202014-metadata.txt
data_roaming=0
default_install_location=0
desk_dock_sound=/system/media/audio/ui/Dock.ogg
desk_undock_sound=/system/media/audio/ui/Undock.ogg
development_settings_enabled=1
device_name=Nexus 6P
device_provisioned=1
dock_audio_media_enabled=1
dock_sounds_enabled=0
emergency_tone=0
guest_user_enabled=1
heads_up_notifications_enabled=1
location_providers_allowed=gps
lock_sound=/system/media/audio/ui/Lock.ogg
low_battery_sound=/system/media/audio/ui/LowBattery.ogg
low_battery_sound_timeout=0
low_power=0
mobile_data=1
mode_ringer=2
multi_sim_data_call=1
multi_sim_sms=1
multi_sim_voice_call=1
netstats_enabled=1
network_scoring_provisioned=1
package_verifier_enable=1
power_sounds_enabled=1
preferred_network_mode1=10
preferred_network_mode=10
send_action_app_error=1
set_install_location=0
sms_short_codes_content_url=http://www.gstatic.com/android/config_update/06012016-sms-blacklist.txt
sms_short_codes_metadata_url=http://www.gstatic.com/android/config_update/06012016-sms-blacklist-metadata.txt
stay_on_while_plugged_in=0
subscription_mode=0
theater_mode_on=0
trusted_sound=/system/media/audio/ui/Trusted.ogg
unlock_sound=/system/media/audio/ui/Unlock.ogg
upload_apk_enable=0
usb_mass_storage_enabled=1
volte_vt_enabled=1
wifi_country_code=GB
wifi_display_on=0
wifi_max_dhcp_retry_count=9
wifi_networks_available_notification_on=1
wifi_on=0
wifi_scan_always_enabled=1
wifi_sleep_policy=2
wifi_watchdog_on=1
wireless_charging_started_sound=/system/media/audio/ui/WirelessChargingStarted.ogg
zen_mode=0
zen_mode_config_etag=-45422432
zen_mode_ringer_level=null

[/tab]
[tab title=”settings list secure”]
accessibility_display_magnification_auto_update=1
accessibility_display_magnification_enabled=0
accessibility_display_magnification_scale=2.0
accessibility_enabled=1
accessibility_script_injection=0

allowed_geolocation_origins=http://www.google.com http://www.google.co.uk
android_id=a902eb2cd83851c8
backup_enabled=1
backup_transport=com.google.android.gms/.backup.BackupTransportService
bluetooth_addr_valid=1
bluetooth_address=
bluetooth_name=Nexus 6P
cdefault_input_method=com.touchtype.swiftkey.beta/com.touchtype.KeyboardService
double_tap_to_wake=1
doze_enabled=0
dropbox:data_app_anr=disabled
dropbox:data_app_crash=disabled
dropbox:data_app_wtf=disabled
enabled_accessibility_services=
enabled_input_methods=enabled_print_services=com.google.android.apps.cloudprint/com.google.android.apps.cloudprint.printdialog.services.CloudPrintService
facelock_detection_threshold=0.0
facelock_liveliness_recognition_threshold=2.2
facelock_max_center_movement=10.0
immersive_mode_confirmations=confirmed
input_methods_subtype_history=install_non_market_apps=1
last_setup_shown=eclair_1
locationPackagePrefixBlacklist=
locationPackagePrefixWhitelist=
location_providers_allowed=gps,network
lock_screen_allow_private_notifications=0
lock_screen_lock_after_timeout=30000
lock_screen_owner_info_enabled=0
lock_screen_show_notifications=1
lockscreen.disabled=0
lockscreen.options=enable_facelock
long_press_timeout=500
masterLocationPackagePrefixBlacklist=com.google.,com.semaphoremobile.zagat.android
masterLocationPackagePrefixWhitelist=com.google.android.gms
media_button_receiver=com.google.android.music/com.google.android.music.playback.MediaButtonIntentReceiver
mock_location=0
mount_play_not_snd=1
mount_ums_autostart=0
mount_ums_notify_enabled=1
mount_ums_prompt=1
nfc_payment_default_component=com.google.android.gms/com.google.android.gms.tapandpay.hce.service.TpHceService
package_verifier_user_consent=1
print_service_search_uri=https://play.google.com/store/apps/collection/promotion_3000abc_print_services
screensaver_activate_on_dock=1
screensaver_activate_on_sleep=0
screensaver_components=com.google.android.deskclock/com.android.deskclock.Screensaver
screensaver_default_component=com.google.android.deskclock/com.android.deskclock.Screensaver
screensaver_enabled=1
seen_tuner_warning=1
selected_input_method_subtype=2131165516
selected_spell_checker=com.google.android.inputmethod.latin/com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService
selected_spell_checker_subtype=0
send_action_app_error=1
serial_blacklist=
show_note_about_notification_hiding=0
sleep_timeout=-1
sms_default_application=com.google.android.talk
speak_password=0
ssl_session_cache=file
touch_exploration_enabled=0
trust_agents_initialized=1
user_full_data_backup_aware=1
user_setup_complete=1
voice_interaction_service=com.google.android.googlequicksearchbox/com.google.android.voiceinteraction.GsaVoiceInteractionService
voice_recognition_service=com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService
volume_controller_service_component=null
wake_gesture_enabled=1
web_autofill_query_url=http://android.clients.google.com/proxy/webautofill
wifi_watchdog_watch_list=GoogleGuest
[/tab]
[/tabs][/toggle]

You can use semicolon to add more than one command to the Tasker run shell.

Run Shell actions in Tasker (root may be required):

[toggle title=”Airplane Mode on/off“]

settings put global airplane_mode_on 1; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
settings put global airplane_mode_on 0; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false

[/toggle]

[toggle title=”Mobile Data on/off“]

svc data enable
svc data disable

[/toggle]

[toggle title=”Check if folder is present (1=no 0=yes)“]

-d /sdcard/DCIM/Camera/ echo 1 || echo 0


Store output %Variable

[/toggle]

[toggle title=”Extract ZIP file (%File)“]

unzip %file /sdcard/

[/toggle]

[toggle title=”Move file, copy file“]

mv /original/path /new/path
cp /original/path /new/path

[/toggle]

[toggle title=”Delete file, delete folder“]

rm /path/to/file
rm -r /path/to/folder

[/toggle]

[toggle title=”Read file, write variable (%var) to file“]

[code language=”shell”]
cat /path/to/file
echo %var > /path/to/file
[/code]

Store output %Variable
[/toggle]

[toggle title=”Make /system rewritable, make system read-only“]

mount -o remount,rw /system
mount -o remount,ro /system

[/toggle]

[toggle title=”Change file permission (/system/etc/hosts as example) file permission types (7=rwx; 6=rw; 4=r) (chmod(root:group;user)) “]

chmod 644 /system/etc/hosts

[/toggle]
[toggle title=”Check the md5sum of the file”]

md5sum /path/to/file

[/toggle]

[toggle title=”Check if process is running (returns process or empty)“]
pgrep -x com.package.name

Store output %Variable
[/toggle]

[toggle title=”Stop current download“]

am force-stop com.android.providers.downloads
pm clear com.android.providers.downloads

[/toggle]

[toggle title=”Kill an app (Chrome in my example)“]

am force-stop com.android.chrome

[/toggle]

[toggle title=”Restart system UI“]

pkill -l TERM -f com.android.systemui

[/toggle]

[toggle title=”Reboot, reboot to recovery“]

svc power reboot
svc power reboot recovery

[/toggle]

[toggle title=”Screenshot to sdcard“]

screencap -p /sdcard/screengrab.jpg

[/toggle]
[toggle title=”Open a URL or website“]

am start -a android.intent.action.VIEW -d http://www.google.com

[/toggle]

[toggle title=”Check if keyboard is out (1=no 0=yes)“]

cat /proc/$(pgrep com.touchtype.swiftkey)/oom_adj

or

dumpsys input_method | grep InputShown

Store output %Variable
[/toggle]

[toggle title=”Ping IP (-c count,-i interval, -s packetsize, -t ttl xxx = IP)“]

ping -c 3 xxx.xxx.xxx.xxx
Store output %Variable

[/toggle]

[toggle title=”Store last input coordinates“]

getevent -lc 3 /dev/input/event1 | grep ABS_MT_POSITION_.


Store output %Variable

[/toggle]

[toggle title=”Emulate user tap input“]

input tap X Y

[/toggle]

[toggle title=”Emulate user long tap input (duration 250)“]

input swipe X1 Y1 X1 Y1 250

[/toggle]

[toggle title=”Emulate text input“]

input text sampletext

[/toggle]

[toggle title=”Emulate user swipe (z = duration)“]

input swipe X1 Y1 X2 Y2 Z

[/toggle]

[toggle title=”Emulate specific key (back in this example)“]

input keyevent 4

List of keyevents:
(please be aware that device screen needs to be ON for this to work)

0 --> "KEYCODE_UNKNOWN"
1 --> "KEYCODE_MENU"
2 --> "KEYCODE_SOFT_RIGHT"
3 --> "KEYCODE_HOME"
4 --> "KEYCODE_BACK"
5 --> "KEYCODE_CALL"
6 --> "KEYCODE_ENDCALL"
7 --> "KEYCODE_0"
8 --> "KEYCODE_1"
9 --> "KEYCODE_2"
10 --> "KEYCODE_3"
11 --> "KEYCODE_4"
12 --> "KEYCODE_5"
13 --> "KEYCODE_6"
14 --> "KEYCODE_7"
15 --> "KEYCODE_8"
16 --> "KEYCODE_9"
17 --> "KEYCODE_STAR"
18 --> "KEYCODE_POUND"
19 --> "KEYCODE_DPAD_UP"
20 --> "KEYCODE_DPAD_DOWN"
21 --> "KEYCODE_DPAD_LEFT"
22 --> "KEYCODE_DPAD_RIGHT"
23 --> "KEYCODE_DPAD_CENTER"
24 --> "KEYCODE_VOLUME_UP"
25 --> "KEYCODE_VOLUME_DOWN"
26 --> "KEYCODE_POWER"
27 --> "KEYCODE_CAMERA"
28 --> "KEYCODE_CLEAR"
29 --> "KEYCODE_A"
30 --> "KEYCODE_B"
31 --> "KEYCODE_C"
32 --> "KEYCODE_D"
33 --> "KEYCODE_E"
34 --> "KEYCODE_F"
35 --> "KEYCODE_G"
36 --> "KEYCODE_H"
37 --> "KEYCODE_I"
38 --> "KEYCODE_J"
39 --> "KEYCODE_K"
40 --> "KEYCODE_L"
41 --> "KEYCODE_M"
42 --> "KEYCODE_N"
43 --> "KEYCODE_O"
44 --> "KEYCODE_P"
45 --> "KEYCODE_Q"
46 --> "KEYCODE_R"
47 --> "KEYCODE_S"
48 --> "KEYCODE_T"
49 --> "KEYCODE_U"
50 --> "KEYCODE_V"
51 --> "KEYCODE_W"
52 --> "KEYCODE_X"
53 --> "KEYCODE_Y"
54 --> "KEYCODE_Z"
55 --> "KEYCODE_COMMA"
56 --> "KEYCODE_PERIOD"
57 --> "KEYCODE_ALT_LEFT"
58 --> "KEYCODE_ALT_RIGHT"
59 --> "KEYCODE_SHIFT_LEFT"
60 --> "KEYCODE_SHIFT_RIGHT"
61 --> "KEYCODE_TAB"
62 --> "KEYCODE_SPACE"
63 --> "KEYCODE_SYM"
64 --> "KEYCODE_EXPLORER"
65 --> "KEYCODE_ENVELOPE"
66 --> "KEYCODE_ENTER"
67 --> "KEYCODE_DEL"
68 --> "KEYCODE_GRAVE"
69 --> "KEYCODE_MINUS"
70 --> "KEYCODE_EQUALS"
71 --> "KEYCODE_LEFT_BRACKET"
72 --> "KEYCODE_RIGHT_BRACKET"
73 --> "KEYCODE_BACKSLASH"
74 --> "KEYCODE_SEMICOLON"
75 --> "KEYCODE_APOSTROPHE"
76 --> "KEYCODE_SLASH"
77 --> "KEYCODE_AT"
78 --> "KEYCODE_NUM"
79 --> "KEYCODE_HEADSETHOOK"
80 --> "KEYCODE_FOCUS"
81 --> "KEYCODE_PLUS"
82 --> "KEYCODE_MENU"
83 --> "KEYCODE_NOTIFICATION"
84 --> "KEYCODE_SEARCH"
85 --> "TAG_LAST_KEYCODE"

[/toggle]

[toggle title=”Get the battery saver profile STATUS/ENABLE/DISABLE“]

settings get global low_power
settings put global low_power 1
settings put global low_power 0

[/toggle]

[toggle title=”Greenify Doze ENABLE/DISABLE“]

am stopservice com.oasisfeng.greenify/.DozeService
pm disable com.oasisfeng.greenify/.DozeService
/
pm enable com.oasisfeng.greenify/.DozeService
am startservice com.oasisfeng.greenify/.DozeService

[/toggle]

[toggle title=”Display your battery level, health and temperature (output needs formatting)“]

dumpsys battery | grep health
dumpsys battery | grep temperature


Store output %Variable

[/toggle]

[toggle title=”Wi-Fi (scanning always available) on/off“]

settings put global wifi_scan_always_enabled 1
settings put global wifi_scan_always_enabled 0

[/toggle]

[toggle title=”Resize the screen and reset“]

wm overscan 150,750,0,0
wm overscan reset

[/toggle]

[toggle title=”Query Wi-Fi (scanning always available) status“]

settings get global wifi_scan_always_enabled
Store output %Variable 

[/toggle]

[toggle title=”Query currently enabled Location providers“]

settings get secure location_providers_allowed
Store output %Variable

[/toggle]

[toggle title=”Query enabled Accessibility Services“]

settings get secure enabled_accessibility_services
Store output %Variable

[/toggle]

[toggle title=”Query enabled Notification Listeners“]

settings get secure enabled_notification_listeners
Store output %Variable

[/toggle]

[toggle title=”Enable an Accessibility Service (AutoInput in my example)“]

settings get secure enabled_accessibility_services
Store output %Variable 
settings put secure enabled_accessibility_services %Variable:com.joaomgcd.autoinput/com.joaomgcd.autoinput.service.ServiceAccessibility

[/toggle]

[toggle title=”Enable a Notification Listener (AutoNotification in my example)“]

settings get secure enabled_notification_listeners
Store output %Variable
settings put secure enabled_notification_listeners %Variable:com.joaomgcd.autonotification/com.joaomgcd.autonotification.service.ServiceNotificationIntercept

[/toggle]

Credits:

I’d like to thank the redditors and xda users who contributed to this lists.

41 COMMENTS

  1. Great but because I’m a beginner could you please tell me how can I access to (or open) shell commands from tasker app , thank you for helping me.

    • Tasks – action – code – run shell. Or just search in the action list by typing. Be aware root will be needed for most.

  2. Great post Mat. I’m trying to get rid of secure settings myself. Do you know of any way to toggle GPS (High Accuracy or Battery Saving mode) via a shell command or an alternative tasker plugin?

  3. You could use:
    location_providers_allowed=gps,network (or list the one you want to use for location)
    with the command syntax
    settings get secure/global/system name_of_the_setting
    settings put secure/global/system name_of_the_setting 0or1
    GET allows you to get the current status of the setting
    PUT allows you to set the setting to your desired value

    • Shame, I don’t use GPS settings as much as I found that battery management is pretty decent in android. Perhaps N will bring some changes

    • Have just found that
      settings put secure location_providers_allowed +gps
      toggles GPS to high accuracy and
      settings put secure location_providers_allowed -gps
      toggles GPS to battery saving mode. You need to be rooted & both settings need the Use Root option to be ticked.

      • A lot of these settings can be extracted as shown in the 1st part of the article. You will find all the device specific settings in 3 lists

  4. Thanks a lot Mat, how can I find status of VPN on my N6p(Android N), I use a VPN app named Shadowsocks,idon’t know which command I can used for toggle it via Manifestviewer.
    Sorry for bad English,thanks again!

    • Each app has their own set of intents. Therefore whatever you wish to do with it may not be supported in this app but could be in another. Check the list of all intents in the app and if nothing sounds similar to what you want to do then try another app. If anything fails you can still toggle things with auto input.

  5. running either: settings list system / settings list global / settings list secure
    tasker just returns me the error:
    usage: settings [–user NUM] get namespace key
    settings [–user NUM] put namespace key value
    settings [–user NUM] delete namespace key

    ‘namespace’ is one of {system, secure, global}, case-insensitive
    If ‘–user NUM’ is not given, the operations are performed on the owner user.

    any idea? shell commands themselves work fine

  6. Are you using ”use root” option? Another thing selecting continue after the error would assure the task keeps running. What is exact command you are using, i will run it on mine.

  7. Yeah, I am using the root option. And shell commands in general work perfectly. I was just interested in checking the whole list on my device.
    I’m trying either of the commands listed and tried some variations, so:
    settings list system
    settings list global
    settings list secure

    • All of them are running ok on my end. Is tasker granted the root permissions? I honestly can’t think why this wouldn’t work for you. What device are you on and what version of Android?

  8. Yes, tasker has root permission. I have a Samsung Galaxy S4 GT-I9505 intl. with Android 5.0.1, Imperium ROM v16.

    Thanks for giving it a thought, but no problem that those 3 commands don’t work for me. All other shell commands I use in tasker work fine.

  9. It might be a silly question but do you put all the 3 lines together? You should use only a single line at the time. Most of the settings available in there are listed by me in the article to use, with some device specific ones. I can’t figure it out why would it cause the issue.

  10. Hi, I tried your shell command for airplane mode on. It works well, airplane mode is switched on and I can see it, being switched on. Nevertheless, wifi and my radio are NOT switched off by it. When I manually switch on airplane mode, it does switch off everything.
    Yes, root is ticked and I’m using a oneplus x with android 6.0.1 / Oxygen 3.1.3

    • Sadly not all version of android and devices are supported. Annoying thing is that these ‘fake’ toggles do work after the reboot.

  11. Yes, sad but true… What do you think of getting secure settings back to work with this workaround in JuiceSSH:
    su
    mount -o remount,rw /system
    touch /sbin/su /system/bin/su /system/xbin/su
    mount -o remount,ro /system
    exit
    reboot
    It works for me, although I am not quite sure if it will cause trouble for me in the future…

  12. I’m on Android 7 and this no longer works. Do test it though. The toggles may change but ie my phone was connecting to the internet even when mobile data was off on the toggle

  13. I need to get system stats about battery use like Wi-Fi time working, phone time working, etc. As can be found in battery stats in OS. I found at reddit command to get SOT, but still missing stats of phone, Wi-Fi etc. How to get it?

  14. Has anyone looked at changing the zen (DND, do not disturb) mode using settings? There are many different settings, some can be changed via settings but others cannot. I don’t know how get the UI to update either.

    settings list global ->
    zen_mode=0 (0,1,3,2 but cannot be changed via settings)
    zen_mode_config_etag=-1866286471 (-1866286471,356998425,1907922690,-1416640260)
    zen_mode_ringer_level=null (null,null,2,2)

    settings –cm list global ->
    zen_mode=0 (can be changed)

    settings –cm list system ->
    zen_priority_allow_lights=1

    • Do you have issues with Tasker do not disturb option ? I run this across few devices and OS and never had an issue?

      • I’d like to be able to use adb to change the DND (do not disturb) mode and was wondering if anyone had made any sense of these “zen” settings.

        • Any issues with a default action – there is DND action in the tasker, I have not heard about any issues with it?

  15. Ahoy,
    On dual-sim phones is there way to change data sim? I’ve tried to change mobile_data0/1/2 values from 0 to 1 and and so. but it only enables/disables data for selected SIM card, so it doesn’t change data sim from one to another. So is there way how can i change data between sims?

    • I’m not sure if this is possible. I’d imagine you need to authorise the change. I’d think this would be pretty insecure if changed with a simple line without authorisation.

  16. Thanks for the article, I’ve been looking for something like this for a while! Just a noob question, how do you turn off an accessibility service once it is enabled? Thanks!

      • Thanks for your answer. I came to this thread from the XDA article about fingerprint actions because it was said that there was a shell alternative to the use of Secure Settings to toggle accessibility services. Maybe you should specify in the XDA article that the alternative allows enabling the accessibility service but not disabling it. Thanks again!

Comments are closed.