2022 Developer Survey is open! Take survey.

Hot answers tagged

90 votes

How to start root shell with Android Studio?

WINDOWS: In the current version of Android Studio, ADB.exe is located in %USERPROFILE%\AppData\Local\Android\sdk\platform-tools\. Earlier versions of Android Studio have it in %LOCALDATA%\Android\sdk\...
user avatar
  • 1,003
66 votes
Accepted

How to start root shell with Android Studio?

Android Studio does not contain ADB, you need Android SDK for it (it is installed on first run of Android Studio 0.9.x and newer). ADB is located in sdk\platform-tools. It's possible to add to PATH ...
user avatar
  • 784
33 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 ...
user avatar
  • 2,908
29 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 # ...
user avatar
  • 23.3k
19 votes

Activate USB tethering from the command line

Running the following command as root should enable USB tethering: service call connectivity 32 i32 1 on Ice Cream Sandwich (4.0) service call connectivity 33 i32 1 on Jelly Bean (4.1 to 4.3) service ...
user avatar
  • 303
17 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 ...
user avatar
  • 171
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 ...
user avatar
  • 23.3k
14 votes
Accepted

Sending intents using ADB with additional action, data, and extra

The Android developer documentation explains how to specify an intent in the argument to the am command. In your case you want -a to specify the action, -d to specify the data URI, and --ez to ...
user avatar
  • 34.3k
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/ ~/...
user avatar
  • 88.9k
11 votes

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

killall zygote This will kill the root zygote process and cause a Android system refresh. This does not restart your phone's hardware, only the Android processes. By default (in Linux), the kill/...
user avatar
  • 293
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 ...
user avatar
  • 119
8 votes

how to turn on/off automatic date/time settings

turn on: settings put global auto_time 1 turn off: settings put global auto_time 0 source: Android sourcecode
user avatar
  • 544
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/<...
user avatar
  • 181
8 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 ...
user avatar
  • 88.9k
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 ...
user avatar
  • 2,908
6 votes

Toggling USB mass storage on (or off) via adb commands

I tried the "StorageManager.enableUsbMassStorage" and the "StorageManager.disableUsbMassStorage" to enable and disable the mass storage and its works. Thanks. That methods are private method. So, ...
user avatar
6 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 ...
user avatar
6 votes

How can I change pointer locations setting in developer options from adb shell?

To enable Pointer locations, the command is: adb shell settings put system pointer_location 1 Change 1 to 0 to disable it. Enter adb shell settings to understand its usage and what the aforesaid ...
user avatar
  • 23.3k
6 votes
Accepted

What does "svc power stayon wireless" do?

Executing svc power on the shell will bring the usage: usage: svc power stayon [true|false|usb|ac|wireless] Set the 'keep awake while plugged in' setting. The command will set whether to ...
user avatar
  • 12.2k
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 ...
user avatar
  • 23.3k
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 ...
user avatar
  • 15.5k
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: ...
user avatar
  • 23.3k
5 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 ...
user avatar
  • 151
5 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 ...
user avatar
  • 23.3k
5 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 ...
user avatar
  • 50.2k
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, ...
user avatar
  • 2,908
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. ...
user avatar
  • 2,908
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 ...
user avatar
  • 191
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 ...
user avatar
  • 23.3k
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 ...
user avatar
  • 576

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