Check your Laptop’s Battery health on Linux

Linux distros are known for draining the battery charge quickly out of Laptops and mobile devices. And although there are many third-party tools such as TLP or Auto-CPUfreq which were developed in order to solve this charge drain issue, we have nowhere been near to the uptime of Windows machines.

Even I have noticed that my laptop on Windows boot offers me up to 10 hours of battery life on Light browsing. And the same device with Fedora workstation 37 along with Auto-CPUfreq installed, still gives me 6 hours of uptime performing the same tasks.

And the more your Laptop’s Battery goes through charge cycles, the more it’s capacity decreases over time. Therefore, we recommend you to use tools like TLPUI and Auto-CPUfreq. However, if let’s say you want to check the health of your battery, how many charge cycles it has gone through and how much it’s current charge capacity is and does it need replacement.

In this tutorial, we will learn how to check your Laptop’s battery health using various command line tools.

Checking your Laptop’s battery health

As mentioned above, we will discuss various CLI tools that will help us determine our device’s battery health, you can choose the method you find easiest to use:

The upower command

Perhaps the simplest method using which you can determine the Battery health and status would be the upower command. It can easily list down all the power sources which your system is using and also can manage power on your system.

In order to display the power sources, you can type the following command in your Terminal:

upower -e
All The Power Sources In My Laptop
All The Power Sources In My Laptop

The first output shows that my device is plugged in and charging, and the third device is the Display Monitor of my laptop, however, we are only interested in the second output which contains the information regarding our battery.

You can display the Battery related information using upower command by typing the following commands in your Terminal:

upower -i /org/freedesktop/UPower/devices/battery_BAT0
Checking Battery Health Of Laptop Using Upower
Checking Battery Health Of Laptop Using Upower

As you can see, the information such as Battery percentage, it’s vendor, state, charge cycles are displayed in a nice table. Battery Health is listed in the table as ‘Battery Capacity’ and it is currently 100% on my system.

Using the ACPI command

The acpi command can also display information related to your laptop’s battery. It stands for Advanced Configuration and Power Interface. Most Linux distributions ship with this command pre-installed, however if you can’t seem to find it, you can install it easily using your default package manager like this:

# On Debian and Ubuntu based distributions:
sudo apt update && sudo apt install acpi

# On Arch Linux based distributions:
sudo pacman -S acpi

# On Fedora or CentOS:
sudo dnf install acpi
Installing The ACPI Command On Fedora
Installing The ACPI Command On Fedora

After installation, you can check your device’s Battery health by typing the following command:

acpi -V
Checking Laptops Battery Health Using The ACPI Commannd
Checking Laptops Battery Health Using The ACPI Command

As you can see in the second line of the output, it says design capacity is 3580 mAh and last full capacity is also 3680 mAh, which means my battery health is currently at 100%.

By listing individual files

As we all know that Linux is designed in such a way that it stores everything in the form of ‘files’. Every hardware that is attached to your system is assigned a specific file. SO, technically, you can check your device’s battery health simply by listing or reading a file without installing any command.

The file/directory associated with your attached batteries is located in /sys/class/power_supply/BAT0 directory. You can list everything stored in that directory by typing:

ls /sys/class/power_supply/BAT0
Listing The Files Under Your Battery Directory
Listing The Files Under Your Battery Directory

As you can see, in this directory there are two files named energy_full and energy_full_design. We can just see the contents of these files in order to display the current charge of your PC and your Battery health.

cat /sys/class/power_supply/BAT0/energy_full
cat /sys/class/power_supply/BAT0/energy_full_design
List Out The Contents Of Files
List Out The Contents Of Files

If you want to check the health, you can just compare the both numbers. If the difference is small, then your battery is in good shape and there is too much difference, then you might want to change your device’s battery.

Summary

As we have already discussed above, you might want to install tools like TLPUI or Auto-CPUfreq if you want to save your battery for a larger duration. Choice of distribution and desktop environment also affects the battery usage, so if you have time you can try out various Linux distributions such as Ubuntu, Fedora, Arch Linux or any of their derivative operating systems.