5 Ways To Check Laptop Battery Status And Level From Linux Terminal
======
We can easily check the battery status through GUI such as current battery percentage, whether it’s charging or not charging and how long it will be usable without charging, but we can’t able to check the battery health and other related information.
In this scenario what will be the solutions.
Yes, we have few utilities available for this in Linux and it can be achieved through command line.
We are going to discuss about this topic today through this article and i will try to cover possible information i can.
Checking your battery health monthly once is something good. It will help you to identify whether we are facing any battery or charge related issues.
Also, we can see battery model name, power source, vendor and battery technology, etc,.
Power management is a feature that turns off the power or switches system’s components to a low-power state when inactive.
### Following Utilities are available in Linux to Check Battery Status.
*`upower`: upower is a command line tool which provides an interface to enumerate power sources on the system.
*`acpi`: acpi Shows information from the /proc or the /sys filesystem, such as battery status or thermal information.
*`batstat`: batstat is a command line tool to print battery status for linux.
*`tlp`: TLP brings you the benefits of advanced power management for Linux without changing any configuration.
*`class file`: The sysfs filesystem is a pseudo-filesystem which provides an interface to kernel data structures.
### How to Check Laptop Battery Status Using upower Command?
[upower][1] is a command line tool that provides an interface to enumerate power sources on the system. It control the latency of different operations on your computer, which enables you to save significant amounts of power.
Just run the following command to get the battery and it’s related information on Linux.
updated: Monday 03 December 2018 07:56:18 PM IST (95 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: discharging
warning-level: none
energy: 28.23 Wh
energy-empty: 0 Wh
energy-full: 52.26 Wh
energy-full-design: 60 Wh
energy-rate: 10.714 W
voltage: 14.819 V
time to empty: 2.6 hours
percentage: 54%
capacity: 87.1%
technology: lithium-ion
icon-name: 'battery-good-symbolic'
History (charge):
1543847178 54.000 discharging
History (rate):
1543847178 10.714 discharging
```
To check the specific information about battery, use the following format.
```
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -i "state\|percentage\|time to empty"
state: discharging
time to empty: 2.1 hours
percentage: 43%
```
It’s same as above, but it’s taken after power cable plugged in, that’s why the state showing charging.
```
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -i "state\|percentage\|time to empty"
state: charging
percentage: 41%
```
### How to Check Laptop Battery Status Using TLP Command?
TLP is a free opensource feature-rich command line tool which optimize laptop battery without making any configuration change.
TLP brings you the benefits of advanced power management for Linux without the need to understand every technical detail. TLP comes with a default configuration already optimized for battery life, so you may just install and forget it. Nevertheless TLP is highly customizable to fulfil your specific requirements.
TLP package is available in most of the Linux distribution official repository such as Arch, Debian, Fedora, Gentoo, openSUSE, etc. Use your distribution Package Manager to install the TLP utility.
Just run the following command to get the battery and it’s related information on Linux.
### How to Check Laptop Battery Status Using ACPI Command?
ACPI stands for Advanced Configuration and Power Interface modules are kernel modules for different ACPI parts. They enable special ACPI functions or add information to /proc or /sys. These information can be parsed by acpid for events or other monitoring applications.
```
$ acpi
Battery 0: Charging, 43%, 01:05:11 until charged
```
To see battery capacity.
```
$ acpi -i
Battery 0: Charging, 43%, 01:05:07 until charged
Battery 0: design capacity 3817 mAh, last full capacity 3324 mAh = 87%
```
To see more details about battery and related information.
```
$ acpi -V
Battery 0: Charging, 43%, 01:05:07 until charged
Battery 0: design capacity 3815 mAh, last full capacity 3323 mAh = 87%
Adapter 0: on-line
Cooling 0: Processor 0 of 10
Cooling 1: Processor 0 of 10
Cooling 2: Processor 0 of 10
Cooling 3: iwlwifi 0 of 19
Cooling 4: Processor 0 of 10
Cooling 5: iwlwifi no state information available
Cooling 6: Processor 0 of 10
Cooling 7: Processor 0 of 10
Cooling 8: Processor 0 of 10
Cooling 9: intel_powerclamp no state information available
Cooling 10: x86_pkg_temp no state information available
Cooling 11: Processor 0 of 10
```
### How to Check Laptop Battery Status Using Batstat Command?
batstat is a command line tool to print battery status in linux terminal.
```
Status: Charging
Max energy: 50.00 Wh
Energy left: 24.50 Wh
Power Consumption: 26.40 W
Percentage left: 49.00%
Average power Consumption: 0.00 W
Time elapsed: 0: 0:12 since 49.00%
= Time ======== Percent ============================================
0: 0: 0 49.00%
```
### How to Check Laptop Battery Status Using sysfs filesystem?
The sysfs filesystem is a pseudo-filesystem which provides an interface to kernel data structures. The files under sysfs provide information about devices, kernel modules, filesystems, and other kernel components.
The sysfs filesystem is commonly mounted at /sys. Typically, it is mounted automatically by the system, but it can also be mounted manually using a command such as `mount -t sysfs sysfs /sys`
Many of the files in the sysfs filesystem are read-only, but some files are writable, allowing kernel variables to be changed. To avoid redundancy, symbolic links are heavily used to connect entries across the filesystem tree.
```
$ cat /sys/class/power_supply/BAT0/*
0
51
Normal
0
cat: /sys/class/power_supply/BAT0/device: Is a directory
52260000
60000000
26660000
SMP
L14M4P23
cat: /sys/class/power_supply/BAT0/power: Is a directory
27656000
1
756
Charging
cat: /sys/class/power_supply/BAT0/subsystem: Is a directory