Checking battery status in Linux command line

If you use Linux in text-mode and have laptop you may want to check your laptop battery status like its percentage or charging battery is finished or not.

I was searching on the net to find a way to check my laptop battery since recently I shifted to fully text-mode (I am novice!) and I found the following topic.

Therefore, I copied some parts of it here. All credit goes back to Lekensteyn.

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

The above command gives total information about your battery but many parts are not useful, so you can filter the output of above command with using grep command like below

$ grep -E "state|to\ full|percentage"

Finally, combination of above commands can be like following

$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|to\ full|percentage"

The mentioned command does not show when battery will be empty and it just shows taken time to battery be full, so I change it a little bit to reflects when battery will be finished as well.

Therefore, it is

$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|time|percentage"

Additionally, there is another way to get total information of you battery and its state as well.

So I copied two below commands from the same topic. All credit goes back to Mariano.

$ cat /proc/acpi/battery/BAT0/state

$ cat /proc/acpi/battery/BAT0/info

Two above commands do not give you information about battery charge percentage and therefore, I rather use upower command instead.

send your idea to kasra.madadipouya@geeksweb.tk

Leave a Reply