# ADB Command Reference ## Table of Contents - [Device Management](#device-management) - [App Management](#app-management) - [File Transfer](#file-transfer) - [Logging](#logging) - [Screenshot & Recording](#screenshot--recording) - [UI Hierarchy](#ui-hierarchy) - [Performance](#performance) - [System Info](#system-info) - [Input & Interaction](#input--interaction) - [Network](#network) - [Dangerous Operations](#dangerous-operations) --- ## Device Management ```bash # List connected devices adb devices -l # Specify device for all commands adb -s # Connect over WiFi adb tcpip 5555 adb connect :5555 # Disconnect WiFi device adb disconnect :5555 # Restart adb server adb kill-server && adb start-server # Device properties adb shell getprop ro.build.version.release # Android version adb shell getprop ro.build.version.sdk # API level adb shell getprop ro.product.model # Device model adb shell getprop ro.product.brand # Brand adb shell getprop ro.serialno # Serial number ``` ## App Management ```bash # Install / reinstall adb install adb install -r # Replace existing adb install -t # Allow test packages adb install -d # Allow downgrade # Uninstall adb uninstall adb uninstall -k # Keep data # List packages adb shell pm list packages # All adb shell pm list packages -3 # Third-party adb shell pm list packages | grep # Filter # App info adb shell dumpsys package | grep versionName adb shell dumpsys package | grep versionCode # Start activity adb shell am start -n / adb shell am start -a android.intent.action.VIEW -d # Force stop adb shell am force-stop # Clear app data adb shell pm clear # Grant / revoke permission adb shell pm grant adb shell pm revoke # List permissions adb shell dumpsys package | grep permission # Dump current activity adb shell dumpsys activity activities | grep mResumedActivity adb shell dumpsys window | grep mCurrentFocus ``` ## File Transfer ```bash # Push file to device adb push # Pull file from device adb pull # List files on device adb shell ls adb shell ls -la # File size adb shell du -sh # Create directory adb shell mkdir -p # Remove file/directory adb shell rm adb shell rm -rf ``` ## Logging ```bash # Basic logcat adb logcat # Clear log buffer adb logcat -c # Filter by tag adb logcat -s # Filter by priority (V/D/I/W/E/F) adb logcat *:E # Errors and above adb logcat :D *:S # Specific tag at Debug+ # Save to file adb logcat -d > logcat.txt # Dump then stop adb logcat -t 1000 > recent.txt # Last 1000 lines # Time filter adb logcat -T "MM-DD HH:MM:SS.mmm" # Crash logs adb logcat -b crash # Buffer info adb logcat -g # Buffer size adb logcat -b main,system,crash # Specific buffers # Process-specific log adb logcat --pid=$(adb shell pidof ) # Common useful filters adb logcat -s AndroidRuntime:E # Runtime crashes adb logcat -s ActivityManager:I # Activity lifecycle ``` ## Screenshot & Recording ```bash # Screenshot adb shell screencap /sdcard/screenshot.png adb pull /sdcard/screenshot.png . adb shell rm /sdcard/screenshot.png # Screen recording (max 180s) adb shell screenrecord /sdcard/video.mp4 adb shell screenrecord --time-limit 30 /sdcard/video.mp4 adb shell screenrecord --size 720x1280 /sdcard/video.mp4 adb shell screenrecord --bit-rate 6000000 /sdcard/video.mp4 # Pull recording adb pull /sdcard/video.mp4 . adb shell rm /sdcard/video.mp4 ``` ## UI Hierarchy ```bash # Dump UI tree to XML (standard) adb shell uiautomator dump /sdcard/ui_dump.xml adb pull /sdcard/ui_dump.xml . adb shell rm /sdcard/ui_dump.xml # Dump compressed (smaller output) adb shell uiautomator dump --compressed /sdcard/ui_dump.xml # Direct stdout dump (no temp file) adb exec-out uiautomator dump /dev/tty # Fallback: text-based view hierarchy via dumpsys adb shell dumpsys activity top -a ``` ## Performance ```bash # Memory info adb shell dumpsys meminfo adb shell dumpsys meminfo # System-wide adb shell cat /proc/meminfo # Raw kernel info # CPU info adb shell dumpsys cpuinfo adb shell top -n 1 -s cpu # Battery stats adb shell dumpsys battery adb shell dumpsys batterystats # GPU rendering profiling adb shell dumpsys gfxinfo # Network stats adb shell dumpsys netstats detail # Disk usage adb shell df -h adb shell du -sh /data/data/ # Process list adb shell ps -A | grep # Thread info for a process adb shell ps -T -p ``` ## System Info ```bash # Full device info adb shell getprop # Display info adb shell wm size # Screen resolution adb shell wm density # Screen density # System settings adb shell settings list system adb shell settings list secure adb shell settings list global # Input methods adb shell ime list -s # Services list adb shell service list # WiFi info adb shell dumpsys wifi | grep "mWifiInfo" # Storage info adb shell sm list-volumes ``` ## Input & Interaction ```bash # Tap at coordinates adb shell input tap # Swipe adb shell input swipe # Type text adb shell input text "" # Key event adb shell input keyevent # Common keycodes: # 3=HOME 4=BACK 24=VOL_UP 25=VOL_DOWN # 26=POWER 82=MENU 187=APP_SWITCH # 66=ENTER 67=DEL 111=ESCAPE # 61=TAB 122=MOVE_HOME 123=MOVE_END # Long press power (reboot menu) adb shell input keyevent --longpress 26 ``` ## Network ```bash # Enable/disable WiFi adb shell svc wifi enable adb shell svc wifi disable # Enable/disable mobile data adb shell svc data enable adb shell svc data disable # Set HTTP proxy adb shell settings put global http_proxy : # Remove HTTP proxy adb shell settings delete global http_proxy # Airplane mode adb shell settings put global airplane_mode_on 1 adb shell am broadcast -a android.intent.action.AIRPLANE_MODE ``` ## Dangerous Operations > These commands may cause data loss or render the device unusable. Always confirm before executing. ```bash # Factory reset adb shell recovery --wipe_data # Flash partition adb reboot bootloader fastboot flash # Wipe app data for ALL apps adb shell pm list packages -3 | while read pkg; do adb shell pm clear ${pkg#package:}; done # Disable system app adb shell pm disable-user --user 0 # Modify system settings adb shell settings put system adb shell settings put secure adb shell settings put global # Change system properties adb shell setprop # Root access adb root adb shell su # Sideload OTA adb sideload # Reboot adb reboot adb reboot recovery adb reboot bootloader ```