Skip to main content
34 votes
Accepted

What is this `adb` utility I keep getting advice to use?

About adb To put it shortly, adb (Android Debug Bridge) is a utility made to be installed on a computer, in order to let it gain a shell on a phone that's either connected via USB cable, or on the ...
Grimoire's user avatar
  • 2,959
20 votes

Enable location services via ADB or shell

On Android 6.0, To enable: GPS: adb shell settings put secure location_providers_allowed +gps Network: adb shell settings put secure location_providers_allowed +network To disable: GPS: adb shell ...
Aditya S's user avatar
  • 301
16 votes
Accepted

How to check if a package is enabled via shell?

pm list packages -d 2>/dev/null will list up all disabled packages, one per line, preceded with the keyword package: – so output looks like package:com.android.exchange package:com.android.email ...
Izzy's user avatar
  • 91.2k
12 votes
Accepted

How to execute commands, after exiting ADB shell?

Write your script a little different: #!/bin/bash adb shell <<EOF ... <open app menu> <open app settings> <save app backup> ... EOF adb pull /storage/emulated/0/Backups/ ~/...
Izzy's user avatar
  • 91.2k
11 votes

adb shell -> su: not found

Your device is not rooted. To see what Rooting is and how to go about doing it: http://www.androidcentral.com/root What does "to root a phone" mean? Once you have rooted your device, you ...
Oli Wood's user avatar
  • 119
9 votes

Send a notification (or just vibrate) to phone via ADB/shell

Use cmd notification: cmd notification post [flags] <tag> <text> If you are root notification will not be displayed: su -lp 2000 -c "cmd notification post -S bigtext -t 'Title' 'Tag' ...
maxmopp's user avatar
  • 91
8 votes

How to start root shell with Android Studio?

On a Mac Android Studio installs adb there: /Users/<your username>/Library/Android/sdk/platform-tools To use it in your shell, you can add it to your .profile file: export PATH=/Users/<...
Christian's user avatar
  • 181
8 votes

How can I run a script on boot?

If you have Magisk installed you can place the .sh to: /sbin/.magisk/img/.core/service.d/ or to /sbin/.magisk/img/.core/post-fs-data.d/ Don't forget to make it executable: chmod +x your-script.sh. ...
H. Hess's user avatar
  • 181
8 votes
Accepted

Activate USB tethering from the command line

If your Android version has svc inbuilt utility, run this command: adb shell svc usb setFunctions rndis This would enable USB tethering. To see what other USB functions are available, run: adb shell ...
Firelord's user avatar
  • 25.2k
8 votes
Accepted

Where can I run a .sh script on Android without root?

/storage/emulated/0 is usually mounted in a way that prevents execution of programs from this location. Therefore even with a set executable bit for your script you won't be able to execute it ...
Robert's user avatar
  • 21k
8 votes
Accepted

Stock Android always using 100% physical memory. How to free it up with ADB?

Android memory management works differently than traditional OS. The main principle is to keep apps in RAM even if they are not used at the moment because the OS never knows when the user switches ...
Robert's user avatar
  • 21k
7 votes

Enable location services via ADB or shell

Android location service comes with different options: High accuracy: gps, network Enable: adb shell settings put secure location_providers_allowed +gps,network Disable: adb shell settings put ...
Parth Naik's user avatar
6 votes

Is it possible to set device's Latitude and Longitude using ADB SHELL?

Alternatively what might also be an option here is to use Appium's io.appium.setting's app. Once that app's installed on the device you can give it permissions and mock location through adb like ...
jmp's user avatar
  • 161
6 votes

__bionic_open_tzdata_path: ANDROID_DATA not set!

For ssh users, following up on @Death Mask Salesman's comment. sshd allows setting up ENV via proper config (from man --pager='less -p ^ENVIRONMENT' ssh): [...] Additionally, ssh reads ~/.ssh/...
sphakka's user avatar
  • 211
6 votes

How to set static IP on command line or adb shell?

You can try using ip command. How it compares to ifconfig Edit: To set up an IP address you can use: ip address add 192.168.0.77 dev eth0 or the long form ip addr add 192.168.0.77/24 ...
harpratap's user avatar
  • 626
6 votes

adb shell error: device not found (Ubuntu)

Check adb devices. If no device shows up follow the steps below. First, check to make sure USB Debugging is enabled. On most devices: Go into 'About Phone', 'About Device', or 'About Tablet' Find '...
Several Circles's user avatar
6 votes

Send a notification (or just vibrate) to phone via ADB/shell

You can setup a Task in Tasker which you can invoke from command-line. The task can be setup with actions of your liking in combination, such as show a notification and vibrate with XYZ pattern. When ...
Firelord's user avatar
  • 25.2k
6 votes
Accepted

List devices/computers that have been authorized for ADB USB Debugging

You can see which devices were authorized by you on your phone to interact with it through adb. You would need root access though. Go into the directory /data/misc/adb/. There would be two files: ...
Firelord's user avatar
  • 25.2k
5 votes

Enable location services via ADB or shell

location_providers_allowed no longer works for Android 10 (API level 29). Instead, you can set the location_mode to LOCATION_MODE_HIGH_ACCURACY with a value of 3: adb shell settings put secure ...
anotherdave's user avatar
5 votes
Accepted

How to write Android shell history to file?

mksh developer here. We disabled persistent history for mksh on Android, in order to not tax the flash memory with too many write requests. You can re-enable it in a custom ROM by setting -...
mirabilos's user avatar
  • 673
5 votes

Using LineageOS native SSHD over ADB

AFAIK with LineageOS 14.1 (I have a rooted FairPhone 2), sshd is enabled by default and ready to use. Its config file is /system/etc/ssh/sshd_config which points to /data/ssh/ for keys storage. I ...
sphakka's user avatar
  • 211
5 votes

How can I see all installed packages, including those that have been hidden?

If you run adb shell pm you would find many options and parameters for pm. One of the parameter is -u to show uninstalled packages. (Hidden packages are treated as uninstalled packages.) On an ...
Firelord's user avatar
  • 25.2k
5 votes

How to run adb and fastboot commands from Termux?

This question is nearly a duplicate of this which has a detailed answer by @Firelord, except the Termux part. As mention by @DeathMaskSalesman in comment, Termux is more like a Linux environment, but ...
Irfan Latif's user avatar
  • 20.8k
5 votes

Why (bind) mounts in /storage/emulated/0 are not visible in apps?

I have been using bind mounts without disabling mount namespaces on Android for a while - Marshmallow (Android 6) and Nougat (Android 7.1, LineageOS 14.1). The bind mount is not visible to other apps ...
Rob W's user avatar
  • 310
5 votes
Accepted

How to screencap the smaller display of Samsung Galaxy Fold using ADB 'screencap' command?

The screencap command can be configured to capture a specific display using the option -d. -d: specify the physical display ID to capture. See dumpsys SurfaceFlinger --display-id for valid ...
Robert's user avatar
  • 21k
5 votes
Accepted

Android stops/pauses execution of my background script?

Android turns off some of CPUs and/or don't let apps use them when it's dozing. It's achieved through Linux kernel's Control Groups. One of the cgroups is cpuset that controls which CPU is assigned to ...
Irfan Latif's user avatar
  • 20.8k
5 votes
Accepted

Is there a way to call/invoke a (private) Java function in an app?

Rooted device On rooted devices private function in apps can be called quite easily (in most cases) using a tool like Frida. Frida is like a mixture of a "scriptable debugger" and Xposed ...
Robert's user avatar
  • 21k
4 votes

Activate USB tethering from the command line

this is device independent (toggles USB tethering) adb shell am start -n com.android.settings/.TetherSettings && adb shell input keyevent 20 && adb shell input keyevent 20 && ...
Zibri's user avatar
  • 173
4 votes

How can I run a script on boot?

I tried all these methods and none of them worked for me. What worked however was based on lord-ralf-adolf's answer here How to run a script on boot in CM12.1? basically, find the file /system/etc/...
Ramast's user avatar
  • 206
4 votes

Enable location services via ADB or shell

Enable: adb shell settings put secure location_mode 3 Disable: adb shell settings put secure location_mode 0 See Stack Overflow - How to enable/disable GPS location services on Android 9 via ADB ...
CoolMind's user avatar
  • 141

Only top scored, non community-wiki answers of a minimum length are eligible