ADB (Android Debug Bridge) shell commands are powerful tools that can help streamline your Android development and debugging workflow. Here are some advanced tips on how to make the most out of ADB shell commands:
1. Setting Up ADB:
- Ensure you have ADB installed as part of the Android SDK on your computer.
- Connect your Android device via USB and enable USB debugging in the developer options.
- Run
adb devicesto verify your device is recognized.
2. Basic Commands:
- Connect to Device:
adb connect [ip_address] - List Devices:
adb devices - Install App:
adb install [app.apk] - Uninstall App:
adb uninstall [package.name]
3. Accessing ADB Shell:
- Access the shell by running
adb shell - Exit shell with
exit
4. File Management:
- Push File to Device:
adb push [source] [destination] - Pull File from Device:
adb pull [source] [destination] - List Files:
adb shell ls [directory]
5. System and App Control:
- Reboot Device:
adb reboot - Reboot to Bootloader:
adb reboot bootloader - Start an App:
adb shell am start -n [package]/[activity] - Stop an App:
adb shell am force-stop [package.name]
6. Network Commands:
- View Network Status:
adb shell netcfgoradb shell ifconfig - Set Up Port Forwarding:
adb forward tcp:[host_port] tcp:[device_port] - Connect ADB Over WiFi:
- Connect via USB and run
adb tcpip 5555 - Disconnect USB and find the IP address of the device with
adb shell ip addr show - Connect via WiFi using
adb connect [device_ip]:5555
- Connect via USB and run
7. Logging and Debugging:
- Logcat Output:
adb logcat - Clear Logcat:
adb logcat -c - Filter Logs by Tag:
adb logcat *:Eoradb logcat -s [tag]:[level] - Capture Bug Report:
adb bugreport [path/to/save]
8. Performance Monitoring:
- CPU Usage:
adb shell top - Memory Usage:
adb shell dumpsys meminfo [package.name] - Battery Stats:
adb shell dumpsys batterystats
9. Customize and Automate:
- Combine ADB commands in shell scripts to automate repetitive tasks.
- Use tools like Tasker on Android to automate system commands based on triggers.
10. Security and Permissions:
- List Permissions:
adb shell pm list permissions - Grant/Deny Permissions:
adb shell pm grant/revoke [package] [permission]
By mastering these ADB shell commands, you can enhance your efficiency in debugging and managing Android devices, simplifying many aspects of development and device maintenance.


