I have a phone with dropbear installed. I usually access my phone over WiFi & run commands in putty.

I want to get battery status & percentage in terminal. Is there any command or program to obtain battery info ?


2 Answers 2


Query the system service battery (possibly requires root access)

dumpsys battery

Output would be like

Current Battery Service state:
  AC powered: false
  USB powered: true
  Wireless powered: false
  status: 2
  health: 2
  present: true
  level: 70
  scale: 100
  temperature: 260
  technology: Li-ion

level: 70 is the battery percentage here.

Not sure about Android 2.3 but this is relevant for at least Android 4.2.1 and above:

(Prefix adb shell next to every command to run the command using adb.)

  • This would give you a list of all the historical broadcasts as well as the sticky ones:

    dumpsys activity broadcasts

    In the output search:

    Sticky action android.intent.action.BATTERY_CHANGED:

    The lines next to it, until you encounter a new sticky broadcast, are useful to us. In my devices, they are listed as:

    Intent: act=android.intent.action.BATTERY_CHANGED flg=0x60000010
    Bundle[{icon-small=17302819, present=true, scale=100, level=100, technology=Li-ion, status=4, voltage=4140, invalid_charger=0, plugged=0, health=2, temperature=200}]

    Assuming that your Android has grep utility, you can shorten the search by using:

    dumpsys activity broadcasts | grep -A2 "Sticky action android.intent.action.BATTERY_CHANGED:"

    (Source: Monitoring the Battery Level and Charging State)

  • Alternative: it is possible to query the battery info from /sys or I should say the Linux kernel.

    /sys/class/power_supply/battery/ has some files with useful information. The file named capacity is equivalent to current battery percentage. You can get an accumulated info from uevent file as well.

    For more and related info, read my answer here.

  • 1
    +1 to that: I can fully confirm the first approach (via dumpsys), which is exactly what I successfully use with Adebar, tested on multiple devices. So your command will probably be something like dumpsys battery | grep "level:" | awk '{ print $2 }'. However, I've never tested that with Android versions <4.
    – Izzy
    Commented Nov 5, 2015 at 11:51
  • Neither did I test on <4, but posted it because OP confirmed it. :) Waiting for somebody to verify the second approach here.
    – Firelord
    Commented Nov 5, 2015 at 12:04
  • 1
    Looks like I can confirm this for cat /sys/class/power_supply/battery/capacity at least on Android 4.1. As sysfs is a Linux feature already available for quite a while, this should work on other/previous Android versions as well. Other "files" in the context of the question: health (e.g. "Good"), status ("Full"), temp (centi-degrees Celsius? here: "300"). Just figuring the current power source might prove a bit tricky :)
    – Izzy
    Commented Nov 5, 2015 at 12:16
  • 1
    still works! cat /sys/class/power_supply/battery/status cool thanks
    – imbr
    Commented May 17, 2021 at 0:33

Script to show battery status on terminal (root required)

Using only the alternative method @Firelord mentioned.

#!/system/bin/sh # might need to change to your sh bin 

    ctype=`cat /sys/class/power_supply/battery/charge_type`
    capacity=`cat /sys/class/power_supply/battery/capacity`
    charging=`cat /sys/class/power_supply/battery/charging_enabled`
    health=`cat /sys/class/power_supply/battery/health`
    status=`cat /sys/class/power_supply/battery/status`
    printf "# %s # %s # %s # %s # %s #\r" "Capacity: ${capacity}" "Charging: ${charging}" "Type: ${ctype}" "Health: ${health}" "Status: ${status}"

while [ true ]
    sleep 1 # 1 second of wait

You might need to adapt the script a bit. Some file names used above are device specific. For example, charging_enable should be replaced by charge_now and some devices, and so on.

It runs and shows status like bellow. To stop it use CRTL+C.

# Capacity: 63 # Charging: 1 # Type: Fast # Health: Good # Status: Charging #

I use this since I do remote ssh on my device. It works even with zygote stopped.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .