Hot answers tagged

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,969
31 votes

How to find out currently running user name/ID from ADB

For Android 8, 9, 10, and possibly for Nougat too I suppose, run: adb shell am get-current-user # returns USER_ID of the foreground user adb shell cmd activity get-current-user # ...
Firelord's user avatar
  • 24.7k
19 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
  • 191
16 votes

What's the best way to restart Android via command line (remotely)?

What is the device doing exactly when I'm pushing the (hardware) power button? I guess that's the most friendly way. You get to see a dialog with an option to power off the device (stock Android ...
Firelord's user avatar
  • 24.7k
14 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
  • 90.6k
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
  • 90.6k
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
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
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
  • 24.7k
8 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
  • 81
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
  • 18.6k
7 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
  • 171
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
7 votes
Accepted

How to kill dhcpcd?

A way to dynamically get the PID of the dhcp process, and kill it altogether, would be to run: su var=$(ps | grep dhcp) kill $(echo -n $var | cut -d " " -f 0) Specifically: line 1 asks for root ...
Grimoire's user avatar
  • 2,969
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
Accepted

How do I install missing command line tools onto an Android device?

For rooted Android devices You can consider installing BusyBox app by Stephen. Per Play Store, the minimum Android version supported by app is Android 1.6 and it is a well-updated app. In essence, it ...
Firelord's user avatar
  • 24.7k
6 votes
Accepted

Run downloaded shell command without root?

Yes, this is by design. You can't execute binaries from the SD card without system or superuser privileges (and remounting it without the noexec option) because otherwise apps could just download and ...
Matthew Read's user avatar
  • 50.5k
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
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
  • 18.6k
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
  • 24.7k
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
  • 24.7k
5 votes

Run downloaded shell command without root?

Android, just as Linux, prevents any user but root, to change the permission bits of any file not owned by such user. That said, chmod is ineffective, unless you have root privileges. By the way, ...
Grimoire's user avatar
  • 2,969
5 votes

Is there a non-app tool for batch backup of APK files?

This script is outdated and no longer supported. For the newest version, which requires Android 5+ and Python 3.5+, and supports Arcus theme variants and Substratum overlays, see my GitHub repository. ...
Grimoire's user avatar
  • 2,969
5 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
  • 201
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
  • 201
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
  • 24.7k
5 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
  • 606
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
  • 18.6k
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
  • 19.7k
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
  • 18.6k

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