Do you want to check your battery health in Ubuntu from the command-line, without needing to install anything extra to do it?

Well, you can.

Most of using Ubuntu on a laptop will monitor our battery level from the top bar (I always enable battery percentage in the top bar for at-a-glance needs), then dive into the Settings > Power panel for a lick more detail if/as/when needed.

However, those methods only show current battery level, i.e., how long until you need to recharge. They won’t tell you anything about the condition of your laptop battery.

If you want more information, Ubuntu pre-installs the Power Statistics utility app. The GUI tool offers updating graphs for charging history, power usage, and a ‘details’ tab with a wealth of information on condition, cycles, and so on.

But if you spend a lot of time in a terminal, prefer it, or you use an Ubuntu flavour, offshoot, or spin that doesn’t include the Power Statistics app by default, no worries: you can quickly find battery condition and other info using the command line.

Perhaps you’ve noticed your laptop needs recharging more often, or that the battery no longer lasts as long as it used to. Batteries have finite lifespans; if you let them empty completely, then recharge fully, repeatedly, it hastens their demise1.

But how many cycles has your battery gone through? And what is its current capacity compared to when it was all shiny and new?

To find that (and more) out using the command line follow the simple steps below.

Find Battery Capacity & Cycle Count from CLI

See battery info from the command line
The steps below work on almost every Linux distribution, not just Ubuntu

Using upower, we can check see the battery vendor, model number, and capacity info, including current max capacity, original max capacity, cycle count, time to empty, and how much power is getting drawn from the battery at the time the command is run.

  1. Open a new Terminal window
  2. Run upower --enumerate
  3. Copy the path printed for your battery (usually ends in _BAT0)
  4. Type upower -i and paste the battery device path

My battery path is /org/freedesktop/UPower/devices/battery_BAT0, per the screenshot, so I run upower -i /org/freedesktop/UPower/devices/battery_BAT0 to glean more details about my battery.

What do the stats presented actually tell you?

The energy-full stat is the maximum charge the battery now holds, energy-full-design is the maximum battery capacity the battery was built to hold, and further down, capacity shows the difference as a percentage.

So in my screenshot you can see my laptop’s battery left the factory able to hold 53.9 Wh. Today, it only holds 38.8 Wh. Which makes the current capacity 71.9% of what it was when new (which for a 6 year old laptop isn’t bad going, I think).

If you’re interested in knowing your cycle count, check the charge-cycles section. This tells you how many times the battery has gone from totally empty to totally charged. In my screenshot, you can see that’s 194 times.

GUI options exist of course

That’s how to check your battery health, current battery capacity, and cycle count from the command line on Ubuntu using upower. This guide is specifically written for those who want to get this info from the command line, not a GUI app.

There are various other ways to get battery information on Ubuntu, and the GUI Power Statistics app Ubuntu includes, which I mentioned at the start, is arguably the most user-friendly of these and it shows you the exact same info.

Still, if you prefer the command line, or don’t have Power Statistics installed on your distro, you can get the pertinent power-related info in a clean, easily grep’d printout using the upower command above.

Over to you: what condition is your battery in and how long have you owned it? Share your stats down in the comments!

  1. Admittedly there is some contention over this, but battery manufactures and hardware vendors like Google and Apple recommend keeping battery levels between 10-90% (some OSes even have ‘optimised charging’ to delay charging past 80%). ↩︎