© 2019-2026 by Zack Smith. All rights reserved.
Introduction
The Android Debugger (ADB) offers surprisingly extensive access to the innards of an Android phone.
The adb command makes it easy to, for instance,
fetch all of your recent photographs and movie recordings off the phone,
and copy podcasts onto the phone.
To jump inside an Android phone and access the command line interface, you will need:
- An Android phone that you have put in Developer Mode.
- A USB cable.
- A computer.
Once you have run your OS's terminal program, there are two ways to ssh into the phone:
If the phone is running a consumer grade (production
) version of Android:
adb shell
If it is running a development build of the OS, you can ssh as root:
adb root
Phone characteristics
Get make and model
getprop ro.product.brand
getprop ro.product.model
System-on-Chip (SoC) characteristics
Get processor family
cat /sys/devices/soc0/family
Get CPU chip name
getprop ro.hardware.chipname
getprop ro.hardware
Get CPU manufacturer
cat /sys/devices/soc0/vendor
For example, Qualcomm.
Get CPU family
cat /sys/devices/soc0/family
For example, Snapdragon.
Determine GPU name
dumpsys | grep GLES:
Get the maximum core frequencies of the CPU
cd /sys/devices/system/cpu
cat cpu*/cpufreq/cpuinfo_max_freq
Get current core frequencies of the CPU
cd /sys/devices/system/cpu
cat cpu*/cpufreq/scaling_cur_freq
Memory and storage
Get RAM available to apps
free -h
grep MemTotal /proc/meminfo
Get flash storage information
df -h
Display
Show display characteristics
Size:
wm size
Frames per second (fps) and dots per inch (DPI):
dumpsys display | grep DeviceInfo
Font size
This is a useful feature if you have trouble reading tiny text.
settings put system font_scale 1.25
Screenshot
screencap /sdcard/screenshot.png
-or
input keyevent 120
Screen recording
screenrecord /sdcard/capture.mp4
Options:
- --time-limit (seconds)
- --rotate
- --bit-rate (Mb/sec)
Note! You may find on some devices that screenrecord is broken. If that is the case with your device, you can still record the screen by swiping down twice from the top of the display, from where you can run Android's built-in recorder GUI.
Screen mirroring to your computer
This is possible with screenrecord and mplayer.
adb exec-out screenrecord --bit-rate=16m --output-format=h264 - | mplayer -framedrop -cache 512 -demuxer h264es -fps 6000 -
Networks
Determine phone carrier
getprop gsm.operator.alpha
getprop gsm.sim.operator.alpha
Display current network connections 1
netstat -e | grep -e tcp -e udp
Display current network connections 2
ss -p -t -4 -6 -u
Turn cellular data on/off
svc data enable
svc data disable
Send an SMS
am start -a android.intent.action.SENDTO -d sms:+15551212 --es sms_body Test --ez exit_on_sent false
Turn the Wifi on/off
svc wifi enable
svc wifi disable
Show Wifi IP address
ifconfig wlan0
List Wifi networks that phone has connected to
dumpsys | grep hasEverConnected=1 | grep ssid=
Show Wifi hotspot name
dumpsys | grep SemSoftApConfiguration
Get the Bluetooth MAC address
settings get secure bluetooth_address
Turn the Bluetooth on/off
svc bluetooth enable
svc bluetooth disable
Get/set the phone's Wifi name
settings get global device_name
settings put global device_name PinePhone2
Turn NFC data on/off
svc nfc enable
svc nfc disable
Camera
The sensors' names are typically in the dumpsys output and are encoded as decimal ASCII values.
- Adb shell to the phone and type
cd /sdcard; dumpsys media.camera > myfile.txt - Copy that file back to your computer (
adb pull /sdcard/myfile.txt) and open it. - Search in that file for
samsung.android.sensor.info.sensorNameand find one entry per sensor, plus maybe an extra one.
Because the sensor name is represented as ASCII decimal values, which you will need to convert it to ASCII e.g. with my converter utility.
Once converted, you may notice a sensor name that begins with IMX
.
That is a Sony sensor (and hopefully not a knock-off).
A sensor name that begins with S5K
is a Samsung sensor.
Here are my phone's sensors:
- 83 53 75 71 87 49 80 = Samsung 64MP S5KGW1P
- 73 77 88 54 49 54 = Sony 32MP IMX616
- 83 53 75 51 76 54 = Samsung 13MP S5K3L6
- 71 67 53 48 51 53 = 5MP GC5035
- 71 67 53 48 51 53 95 77 65 67 82 79 = 5MP GC5035_MACRO
Apps
List all apps
pm list packages
List third-party apps
pm list packages -3
List running apps
ps -fA | grep u0_ | sed 's/^.*:[0-9][0-9] //' | sort
Determine which core an app is running on
ps -o pid,psr,time,comm -p $(pgrep -x programName)
Delete an app
Remove an app easily (in this case Webex) with this command:
pm uninstall com.cisco.webex.meetings
If you see an error, you may need to add --user 0 after uninstall
.
Like so:
pm uninstall --user 0 com.sec.android.app.safetyassurance
pm uninstall --user 0 com.google.android.safetycenter.resources
pm uninstall --user 0 com.samsung.safetyinformation
Clear an app's data
Clear out the data associated with an app (in this case Audible's book data) thus:
pm clear com.audible.application
Remove Samsung's game bloatware
pm uninstall --user 0 com.samsung.android.game.gos
pm uninstall --user 0 com.samsung.android.game.gamehome
pm uninstall --user 0 com.samsung.android.game.gametools
Disable Samsung Cloud
pm uninstall --user 0 com.samsung.android.scloud
Remove other Samsung bloat
pm uninstall --user 0 com.samsung.android.kidsinstaller
pm uninstall --user 0 com.android.providers.partnerbookmarks
pm uninstall --user 0 com.samsung.android.smartswitchassistant
pm uninstall --user 0 android.autoinstalls.config.samsung
Remove Youtube Music
pm uninstall --user 0 com.google.android.apps.youtube.music
Remove Google One
pm uninstall --user 0 com.google.android.apps.subscriptions.red
Remove built-in Facebook apps
Some phone carriers stealthily include Facebook apps on low-end phones. These may run automatically in the background but not appear in the Apps drawer. This is a security concern.
pm uninstall --user 0 com.facebook.services
pm uninstall --user 0 com.facebook.system
pm uninstall --user 0 com.facebook.appmanager
pm uninstall --user 0 com.facebook.katana
Even after all Facebook apps are remove, you may still observe (by using the ss command) periodic connections to Facebook servers such as 2a03:2880:f034:112:face:b00c:0:2.
Disable built-in Microsoft apps
pm suspend com.microsoft.appmanager
pm suspend com.microsoft.skydrive
Set up a Linux-like command-line environment
While you can log in via ADB, you can't use a compiler, Python, or other useful packages.
To set up a proper command-line environment with a compiler and editor, install Termux.
If you want to use it properly, you should connect a keyboard via the USB-C port.
Home screen
Prevent swipe-right from Home into nauseating news
screen
In Android 11, swiping right from the first home screen takes you to a clickbait news page.
This was briefly disableable via ADB but now doing so requires using Android's menus.
To disable it, swipe into the news screen, tap the menu button, tap Settings and disable personalized news from there.
Samsung Bixby
Remove Bixby
pm uninstall --user 0 com.samsung.android.app.spage
pm uninstall --user 0 com.samsung.android.bixby.service
On-screen keyboards
Remove Samsung keyboard
pm uninstall -k --user -0 com.sec.android.inputmethod
Mounting the file system from Linux
Using Media Transfer Protocol (MTP)
This is a very useful feature for directly accessing media files. It might be finnicky about other types of files. If you have large videos or large numbers of photos on your Android device, this will let you skip the process of transferring those to your Linux computer just to find out some were not worth keeping.
- Install the software:
sudo apt update
sudo apt install mtp-tools jmtpfs gvfs-backends gvfs-fuse
- Mount /sdcard:
mkdir ~/Android
jmtpfs ~/Android
- Unmount it:
fusermount -u ~/Android
To detect MTP file systems, use this:
mtp-detect
Using ADBFS
My distro (Debian) doesn't have this program, but it is written in Go and can be found on Github.
sudo apt install adbfs
mkdir ~/Android
adbfs ~/Android
Vibrator
Vibrate for a specified number of milliseconds. This works with Android 9. It may not work in Android 11 and later.
cmd vibrator vibrate 100
To find out what the vibrator can do:
cmd vibrator capabilities
On newer Android versions, this will list vibrator devices:
cmd vibrator_manager list
Simulating input events
Power
* Press power key = input keyevent 26
* Make device sleep = input keyevent KEYCODE_POWER
* Make device wake up = input keyevent KEYCODE_WAKEUP
Go to Home screen
input keyevent 3
Go back
input keyevent 4
Camera app
* Launch the app: input keyevent 27
* Take a photo: input keyevent 108 (this is the Start button)
* Switch to single-take mode: input keyevent 105
* Switch to video capture mode: input keyevent 104
Go to app switcher
input keyevent 187
Launch contacts app
input keyevent 207
Launch calendar app
input keyevent 208
Launch music app
input keyevent 209
Launch phone app
input keyevent 5 (launch phone app)
input keyevent 6 (hang up)
input keyevent 79 (''headset hook'' = hang up call, stop media playback)
input keyevent 164 (mute output)
input keyevent 91 (mute microphone)
Launch web browser
input keyevent 64
Launch mail application
input keyevent 65
Brightness
* Increase = input keyevent 221
* Decrease = input keyevent 220
Sound volume
* Increase = input keyevent 24
* Decrease = input keyevent 25
* Mute = input keyevent 164
Clipboard
* Cut = input keyevent 277
* Copy = input keyevent 278
* Paste = input keyevent 279
Google search
input keyevent 84
Menus
input keyevent 101 (show or hide menu)
Tabs
- Close current tab = input keyevent 97
- Next tab = input keyevent 103
- Previous tab = input keyevent 102
Cursor
input keyevent 19 (move cursor up)
input keyevent 20 (move cursor down)
Scrolling
input keyevent 92 (page up)
input keyevent 93 (page down)
input keyevent 122 (home)
input keyevent 123 (end)
Media players
To start playing the current song or audio book:
media dispatch play
-or-
input keyevent 126
To stop playing the current song or audio book:
media dispatch stop
-or-
input keyevent 127
To launch the media player and play a video:
am start -a android.intent.action.VIEW -d file:///sdcard/video.mkv -t video/mkv
To launch the media player and play a sound:
am start -a android.intent.action.VIEW -d file:///sdcard/sound.ogg -t audio/ogg
Power
Reboot
reboot
svc power reboot
Power down
svc power shutdown
Backup and restore
The backup mechanism will NOT save your contacts. If possible store those on your SIM card.
adb backup -all -apk -nosystem -f mybackup.ab
Restore (I have not verified that this works):
adb restore mybackup.ab
Factory restore
Do this at your own risk!
Don't forgot to:
- Write down your PIN and Google account details.
- Perform a backup.
The PIN will be needed to set up Android.
- Turn off the device.
- Press Volume Up and Power at the same time and hold them.
- When the company logo appears, release only the power button.
- When the Android logo appears, release the volume button.
- This should give you a menu that will let you
wipe data and factory reset
or similar.
From the command line:
adb reboot recovery
Access service mode
*#0011#
Scam block
#662# to enable Scam Block
#664# to enable Scam ID
#632# to disable both.
Links