Programming, tutorials, mechatronics, operating systems, and other tech stuff

How to check battery status in ubuntu using command terminal

1 comment
On linux, we can find out information and status of the battery through the terminal. Here's a very short tutorial on how to see the status of the battery through terminal with upower command, and a tips to make it lot easier.

Upower is an abstraction for enumerating devices, power devices, activity monitor and update the query history and statistics. Created by Information and complete documentation can be visited at

To view battery information, the first is to search path for device battery with the command:

upower -e

Then some device path will show up like example below:


If it the device path list does not appear like above, but instead the error message "command not found" that means upower is not installed (Which is very rare occasion in linux OS). Please install first upower with command:
sudo apt-get install upower
for ubuntu, debian, mint and it's kind.

Each of 3 paths above pointing to the power devices, such as, in the above example is the line power (AC adapter), battery, and display device.

After we figure out the path for the battery, in the case above, it's /org/freedesktop/UPower/devices/battery_BAT0, then we can check the battery status with the command:

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

It will output some information like below:

native-path:          BAT0
vendor:               <a class="zem_slink" title="Laptop" href="" target="_blank" rel="wikipedia">NOTEBOOK</a>
model:                BAT
serial:               0001
power supply:         yes
updated:              Sat 29 Aug 2015 10:51:07 PM WIB (107 seconds ago)
has history:          yes
has statistics:       yes
present:             yes
rechargeable:        yes
state:               discharging
warning-level:       none
<a class="zem_slink" title="Energy" href="" target="_blank" rel="wikipedia">energy</a>:              19.9911 Wh
energy-empty:        0 Wh
energy-full:         31.3797 Wh
energy-full-design:  48.84 Wh
energy-rate:         12.9156 W
voltage:             14.8 V
time to empty:       1.5 hours
percentage:          63%
capacity:            64.25%
technology:          <a class="zem_slink" title="Lithium-ion battery" href="" target="_blank" rel="wikipedia">lithium-ion</a>
icon-name:          'battery-full-symbolic'
History (charge):
1440863467    63.000    discharging
History (rate):
1440863467    12.916    discharging

From the information above, we know that my laptop isn't connected to a charger / power source (state = discharging). Battery energy (energy) 19.9911 Wh or percentage.

Full battery (energy-full) 31.3797 Wh. Which means my battery life have been degraded, and could only be charged until it reach 31.3797 Wh, which is, by design, supposed to be (energy-full-design) 48.84 Wh. Its max capacities (capacity) has been reduced from the original 64.25% (new).

You may experiment and observe other information.

How to make a shortcut to check laptop batteries in terminal

Now to make it even easier, we can create a command alias/shortcut for the above commands.

It's as simple as editiing the .bashrc file. in your home directory:

nano ~/.bashrc

If the file does not exist (empty), try to replace it with the file. bash_profile or. profile.

And then on top of the lines, add the line:

alias battery='upower -i /org/freedesktop/UPower/devices/battery_BAT0'

change 'battery' onto whatever word you like without any spaces.

Save and execute:

source ~/.bashrc

to reload your .bashrc or .bash_profile flle.

Then try your newly defined alias.

1 comment :