×

Check Laptop Battery Health in Ubuntu from the Command Line

Check Laptop Battery Health in Ubuntu from the Command Line


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 fetch more information about it.

Now, the path to your battery may differ from the example above but on most laptops I use this on it’s always the same.

What do the stats actually tell you?

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

In my screenshot you can see my laptop’s battery left the factory designed to hold 53.9 Wh. Now it only holds 38.8 Wh. The current capacity is now 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, the charge-cycles label tells you how many times the battery has been totally flat to totally charged. In my screenshot, you can see that’s 194 time.

GUI options exist of course

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

Of course, 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.

But if you prefer the command line, and you want all that info in one clean, easily grep’d printout, then the upower command above are handy to know.

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



Source link