How To Check Laptop Battery Status In Terminal In Linux

Check Laptop Battery Status In Terminal In Linux

Finding your Laptop battery status in GUI mode is easy. You could easily tell the battery level by hovering the mouse pointer on the battery indicator app in the task bar. But, how about from the command line? Not everyone know this. I was asked this question from one of the user. Here is some simple commands that will help you to check Laptop battery status in Terminal in any Linux distribution.

Check Laptop Battery Status In Terminal In Linux

We can use upower and acpi commands to find out the battery status from command line. Upower command comes preinstalled with most Linux distributions. First let us see how to check battery status using upower command.

1. Check Laptop Battery Status In Terminal using ‘upower’ command

Fire up the Terminal and run:

upower -i /org/freedesktop/UPower/devices/battery_BAT0

Sample output:

native-path: BAT0
vendor: Sanyo
model: DELL 4YRJH22
serial: 5390
power supply: yes
updated: Wed 07 Dec 2016 05:24:15 PM IST (5 seconds ago)
has history: yes
has statistics: yes
battery
 present: yes
 rechargeable: yes
 state: fully-charged
 warning-level: none
 energy: 48.6 Wh
 energy-empty: 0 Wh
 energy-full: 48.6 Wh
 energy-full-design: 48.6 Wh
 energy-rate: 0.0108 W
 voltage: 12.421 V
 percentage: 100%
 capacity: 9.68889%
 technology: lithium-ion
 icon-name: 'battery-full-charged-symbolic'

If the above command doesn’t work for any reason, try the following command instead:

upower -i `upower -e | grep 'BAT'`

Sample output:

native-path: BAT0
vendor: Sanyo
model: DELL 4YRJH22
serial: 5390
power supply: yes
updated: Wed 07 Dec 2016 05:30:15 PM IST (101 seconds ago)
has history: yes
has statistics: yes
battery
 present: yes
 rechargeable: yes
 state: fully-charged
 warning-level: none
 energy: 48.6 Wh
 energy-empty: 0 Wh
 energy-full: 48.6 Wh
 energy-full-design: 48.6 Wh
 energy-rate: 0.0108 W
 voltage: 12.422 V
 percentage: 100%
 capacity: 9.68889%
 technology: lithium-ion
 icon-name: 'battery-full-charged-symbolic'

The above commands will list the complete details of your Laptop battery such as model, vendor name, serial no, state, voltage etc.

However, you can only display the status of the battery by with combination of upower and grep commands as shown below.

upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage"

Sample output:

state: fully-charged
percentage: 100%

As you see in the above output, my Laptop battery has been fully charged.

2. Check Laptop Battery Status In Terminal using ‘acpi’ command

You might need to install acpi command in some Linux distributions.

To install acpi on Debian, Ubuntu and its derivatives:

sudo apt-get install acpi

On RHEL, CentOS, Fedora:

sudo yum install acpi

Or,

sudo dnf install acpi

On Arch Linux and its derivatives:

sudo pacman -S acpi

Once acpi installed, run the following command:

acpi -V

Note: Here, “V” is capital letter.

Sample output:

Battery 0: Full, 100%
Battery 0: design capacity 4500 mAh, last full capacity 436 mAh = 9%
Adapter 0: on-line
Thermal 0: ok, 65.5 degrees C
Thermal 0: trip point 0 switches to mode critical at temperature 84.0 degrees C
Cooling 0: Processor 0 of 3
Cooling 1: Processor 0 of 3
Cooling 2: LCD 0 of 15
Cooling 3: Processor 0 of 3
Cooling 4: Processor 0 of 3
Cooling 5: x86_pkg_temp no state information available

Let us only check the state of the charge of battery. To do so, run:

acpi

Sample output:

Battery 0: Full, 100%

Let us check the battery temperature:

acpi -t

Sample output:

Thermal 0: ok, 63.5 degrees C

Let us view the above output in Fahrenheit:

acpi -t -f

Sample output:

Thermal 0: ok, 144.5 degrees F

Want to know whether the AC power is connected or not? Run:

acpi -a

Sample output:

Adapter 0: on-line

That’s all for today folks. There might be many commands to check the laptop battery status in Terminal in Linux. As far as I know, the above commands worked pretty well as expected. If you know some other commands to find out the battery status, let me know in the comment section below. I will update commands in the article if they works.

Cheers!

Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You may also like...

  • Tractorman2011

    Thanks! You might mention that the “V” in “acpi -V” is capitalized. Took me several tries to figure that out.

    • SK

      I have updated the guide as you suggested. Thanks.

  • Rizwan Mohammed

    On CentOS how come ‘sudo apt-get install acpi’ will work ??????

    • SK

      Good catch. Corrected now. Thank you.