G33K-TRICKS: Complete List of ADB shell Commands for Android mobile

Sunday, May 23, 2021

Complete List of ADB shell Commands for Android mobile


List of adb shell commands
ADB SHELL COMMANDS LIST


Firstly, what is ADB?

Android Debug Bridge(adb) is a command-line tool that lets you communicate with an Android device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device. It is a client-server program that includes three components:

A customer, which sends commands. The customer runs on your development machine. You can bring a customer from a command- line terminal by issuing an adb command.
A daemon( adbd), which runs commands on a device. The daemon runs as a background process on each device.
A garçon, which manages communication between the customer and the daemon. The garçon runs as a background process on your development machine.
adb is included in the Android SDK Platform- Tools package. You can download this package with the SDK Manager, which installs it atandroid_sdk/ platform- tools. Or if you want the standalone Android SDK Platform- Tools package, you can download it then

adb is included in the Android SDK Platform-Tools package. You can download this package with the SDK Manager, which installs it at android_sdk/platform-tools/. Or if you want the standalone Android SDK Platform-Tools package, you can download it here.

For information on connecting a device for use over ADB, including how to use the Connection Assistant to troubleshoot common problems, see Run apps on a hardware device.


  • Below is the comprehensive List of ADB commands that are used regularly
    adb sideload

  • adb shell settings
  • adb shell dumpsys
  • adb shell wm
  • adb shell dumpsys battery
  • adb shell pm
  • adb shell input keyevent <>
  • adb shell input text
  • adb shell input tap
  • adb shell cat
  • adb shell top
  • adb shell ifconfig
  • adb shell screenrecord
  • adb shell screencap
  • adb shell mount
  • adb shell date
  • adb shell netstat
  • adb shell ps
  • adb install
    • adb uninstall
    • adb root
    • adb pull
    • adb push
    • adb shell am
    • adb shell ping


adb sideload

adb sideload ota_file.zip

Updating Phones OTA Images manually via command.

Prior to this need to take phone to recovery mode (adb reboot recovery)


adb shell dumpsys iphonesubinfo

adb shell dumpsys iphonesubinfo

Get Android device IMEI (Only for Android 4.4 or lower, otherwise needs ROOT permission)


adb shell getprop

adb shell getprop

Get Android system properties info.


adb shell getprop ro.build.version.sdk

Get SDK API level.


adb shell getprop ro.build.version.security_patch

Get Android security patch version.


adb shell getprop ro.board.platform

Get SOC info.


adb shell getprop ro.build.version.release

Get Android version info.

  

adb shell getprop ro.vendor.product.model

Get Android device model.


adb shell getprop ro.product.manufacturer

Get Android device manufacturer.

 

adb shell getprop ro.serialno

Get ADB serial number.


adb shell getprop ro.oem_unlock_supported

Get OEM unlock status.


adb shell getprop ro.bootimage.build.fingerprint

Get Android device build fingerprint.


adb shell getprop ro.boot.wifimacaddr

Get WiFi MAC Address



adb shell settings

adb shell settings list system

Android Settings provider (system namespace)


adb shell settings get system volume_system

Get current system volume level in Android.


adb shell settings get system notification_sound

Get current system notification sound in Android.

 

adb shell settings list secure

Android Settings provider (secure namespace)


adb shell settings get secure android_id

Find Android Device Identifier(Device Id)


adb shell settings get secure bluetooth_address

Find Bluetooth MAC address in android.

 

adb shell settings list global

Android Settings provider (global namespace)


adb shell settings get global mobile_data

Get current mobile data status in Android.


adb shell settings get global wifi_on

Get current WiFi status in Android.



adb shell pm

adb shell pm list packages

Get List of Installed Apps in Android.


adb shell pm list packages -s

Get list of System apps


Other params:

-d : Disabled apps

-e : Enabled apps

-u : Uninstalled apps


adb shell pm list packages -3

lists 3rd-Party apps


adb shell pm list packages <keywords>

Keyword filtering


adb shell pm path <package-name>

Get the APK path on the device's filesystem


adb shell pm uninstall <package name>

-k - keeps the app data and cache as is on mobile

e.g. adb shell pm uninstall -k --user 0 com.facebook.appmanager



adb shell pm disable-user --user 0 <package name>

to disable a system app on your Android mobile device



adb shell pm hide -user 0 <package name>

to hide an app from device


adb shell pm create-user <username>

to create another user on the device


adb shell pm remove-user <user_id>

to remove another user on the device



adb shell wm

adb shell wm density

Get screen physical density in Android


adb shell wm size

Get screen physical size in Android


adb shell dumpsys battery

adb shell dumpsys battery

Get battery info in Android.


Current Battery Service state:

 AC powered: false

 USB powered: true

 Wireless powered: false

 Max charging current: 500000

 Max charging voltage: 5000000

 Charge counter: 3367082

 status: 2

 health: 2

 present: true

 level: 98

 scale: 100

 voltage: 4393

 temperature: 325

 technology: Li-ion


adb shell pm

adb shell pm list packages

Get List of Installed Apps in Android.


adb shell pm list packages -s

System apps


adb shell pm list packages -3

3rd-Party apps


adb shell pm list packages <keywords>

Keyword filtering


adb shell pm path <package-name>

Get the APK path on the device's filesystem.


adb shell pm list features

lists phone features



adb shell input keyevent

adb shell input keyevent [--longpress] <key code number or name>

Control Keypress events on Android


Android KeyEvent Constants


adb shell input keyevent 187

KEYCODE_APP_SWITCH


adb shell input keyevent 3

KEYCODE_HOME


adb shell input keyevent 84

KEYCODE_SEARCH

 

adb shell input keyevent 219

KEYCODE_ASSIST


adb shell input keyevent 231

Voice Assist key


adb shell input keyevent 5

KEYCODE_CALL


adb shell input keyevent 6

KEYCODE_ENDCALL


adb shell input keyevent 7

KEYCODE_0 


adb shell input keyevent 16

KEYCODE_9


adb shell input keyevent 29

KEYCODE_A


adb shell input keyevent 54

KEYCODE_Z


adb shell input keyevent 66

KEYCODE_ENTER


adb shell input keyevent 67

KEYCODE_DEL


adb shell input keyevent 24

KEYCODE_VOLUME_UP


adb shell input keyevent 25

KEYCODE_VOLUME_DOWN


adb shell input keyevent 164

toggle MUTE the speaker


adb shell input keyevent 91

toggle MUTE the microphone


adb shell input keyevent --longpress 26

Long PRESS power key


adb shell input keyevent 26

KEYCODE_POWER


adb shell input keyevent 27

KEYCODE_CAMERA

 

adb shell input keyevent 223

Lock screen.

 

adb shell input keyevent 224

Wakes up the device.



adb shell input text

adb shell input text <string>

Sending Keyboard input to your Android device.


adb shell input text Nexus


adb shell input text ADB%sInstaller

Tips: %s means SPACE, replace spaces with %s



adb shell input tap

adb shell input tap <x> <y>

Simulate a touchscreen tap X,Y position.


adb shell input tap 620 1300

To find the exact X,Y position go to "Settings" > "Developer Options" > Check the option "Pointer location"


adb shell cat

adb shell cat /proc/cpuinfo

CPU Info


adb shell cat /proc/meminfo

RAM Info


adb shell top

adb shell top

The top command allows users to monitor processes and system resource usage on Linux.


adb shell ifconfig

adb shell ifconfig

Display or configure network interface


adb shell ifconfig wlan0

WiFi Connection Info



adb shell screenrecord

adb shell screenrecord /sdcard/test.mp4

Records the device's display to a .mp4 file


adb pull /sdcard/test.mp4

Download test.mp4 file from Android Device.


adb shell screenrecord [options] <filename>


Options:


--size WIDTHxHEIGHT

  Set the video size, e.g. "1280x720". Default is the device's main

  display resolution (if supported), 1280x720 if not. For best results,

  use a size supported by the AVC encoder.


--bit-rate RATE

  Set the video bit rate, in bits per second. Value may be specified as

  bits or megabits, e.g. '4000000' is equivalent to '4M'. Default 20Mbps.


--bugreport

  Add additional information, such as a timestamp overlay, that is helpful

  in videos captured to illustrate bugs.


--time-limit TIME

  Set the maximum recording time, in seconds. Default / maximum is 180.


--verbose

  Display interesting information on stdout.



adb shell screencap

adb shell screencap -d 0 /sdcard/test.png

Take a screenshot on Android


adb shell pull /sdcard/test.png

Download test.png file from Android Device.



adb shell mount

adb shell mount

Mount new filesystem(s) on directories. With no arguments, display existing mounts.


mount [-afFrsvw] [-t TYPE] [-o OPTION,] [[DEVICE] DIR]


-a   mount all entries in /etc/fstab (with -t, only entries of that TYPE)

-O   only mount -a entries that have this option

-f   fake it (don't actually mount)

-r   read only (same as -o ro)

-w   read/write (default, same as -o rw)

-t   specify filesystem type

-v   verbose


OPTIONS is a comma separated list of options, which can also be supplied as --longopts.


This mount autodetects loopback mounts (a file on a directory) and bind mounts (file on file, directory on directory), so you don't need to say --bind or --loop. You can also "mount -a /path" to mount everything in /etc/fstab under /path, even if it's noauto


adb shell date

adb shell date

Get the current datetime


adb shell netstat

adb shell netstat

Display networking information. Default is netsat -tuwx


-r routing table

-a all sockets (not just connected)

-l listening server sockets

-t TCP sockets

-u UDP sockets

-w raw sockets

-x unix sockets

-e extended info

-n don't resolve names

-W wide display

-p PID/Program name of sockets



adb shell ps

adb shell ps

List processes running in the android 


Which processes to show (selections may be comma separated lists):


-A   All processes

-a   Processes with terminals that aren't session leaders

-d   All processes that aren't session leaders

-e   Same as -A

-g   Belonging to GROUPs

-G   Belonging to real GROUPs (before sgid)

-p   PIDs (--pid)

-P   Parent PIDs (--ppid)

-s   In session IDs

-t   Attached to selected TTYs

-T   Show threads

-u   Owned by USERs

-U   Owned by real USERs (before suid)


Output modifiers:


-k   Sort FIELDs in +increasing or -decreasting order (--sort)

-M   Measure field widths (expanding as necessary)

-n   Show numeric USER and GROUP

-w   Wide output (don't truncate fields)


adb install

adb install test.apk

app installation


install [-lrtsdg] [--instant] <PACKAGE-NAME>

install-multiple [-lrtsdpg] [--instant] PACKAGE...push package(s) to the device and install them


-l: forward lock application

-r: replace existing application

-t: allow test packages

-s: install application on sdcard

-d: allow version code downgrade (debuggable packages only)

-p: partial application install (install-multiple only)

-g: grant all runtime permissions

--instant: cause the app to be installed as an ephemeral install app


adb uninstall

adb uninstall <PACKAGE-NAME>

remove this app package from the device



adb root

adb root

restart adbd with root permissions


adb unroot

restart adbd without root permissions


-k: keep the data and cache directories



adb pull

adb pull /sdcard/test.png

copy files/dirs from device


-a: preserve file timestamp and mode


adb push

adb push test.png /sdcard/test.png

copy local files/directories to device


--sync: only push files that are newer on the host than the device


adb shell am

adb shell am

Activity manager (activity) commands


adb shell am start -n com.android.vending/com.google.android.finsky.activities.MainActivity

Launch Google Play Store



adb shell ping

adb shell ping www.yahoo.com

pings www.yahoo.com



adb shell ls

adb shell ls

list directory contents


adb shell ls -s 

print size of each file


adb shell ls -R 

list subdirectories recursively


Other Generic Commands commonly used:

adb reboot-recovery (reboot device into recovery mode)

adb reboot fastboot (reboot device into fastboot mode)
adb reboot bootloader  - Reboots the device to the bootloader
adb shell screencap -p "/path/to/screenshot.png" (capture screenshot)
adb shell screenrecord "/path/to/record.mp4" (record device screen)
adb backup -apk -all -f backup.ab (backup settings and apps)
adb backup -apk -shared -all -f backup.ab (backup settings, apps and shared storage)
adb backup -apk -nosystem -all -f backup.ab (backup only non-system apps)
adb restore backup.ab (restore a previous backup)
adb shell am start|startservice|broadcast <INTENT>[<COMPONENT>]
-a <ACTION> e.g. android.intent.action.VIEW
-c <CATEGORY> e.g. android.intent.category.LAUNCHER
 (start activity intent)

adb shell am start -a android.intent.action.VIEW -d URL (open URL)
adb shell am start -t image/* -a android.intent.action.VIEW (opens gallery)

adb shell permissions groups (list permission groups definitions)
adb shell list permissions -g -r (list permissions details)

adb shell ip -o a - To get list of all IP Address

adb shell ip addr show wlan0 - 

adb shell "svc data disable" - Disables the Mobile Data

adb shell "svc data enable" - Enables the Mobile Data

adb shell ip addr show wlan0 - Shows Wlan0 IP config.

Output:

11: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

    link/ether aa:84:17:9c:df:1b brd ff:ff:ff:ff:ff:ff

    inet 192.168.0.27/24 brd 192.168.0.255 scope global wlan0

       valid_lft forever preferred_lft forever

    inet6 fe80::a884:17ff:fe9c:df1b/64 scope link 

       valid_lft forever preferred_lft forever


adb shell getevents  (tool runs on the device and provides information about input devices and a live dump of kernel input events)





No comments: