Find battery usage details from Ubuntu terminal

Requirement

I usually connect to my laptop using SSH from my workstation. At times I need to check the battery remaining on the laptop. In order to do this I need to remote desktop into the laptop. Since this is a small task, I don’t want to remote desktop to the laptop every time.

Solution

There is no doubt that the Linux Terminal is very powerful. In this case as well I can get the battery information right from the terminal. Upower is what we will use for this task.

Executing the above code will enumerate and list the power devices attached to the computer. Here is what was returned on my laptop.

As highlighted battery_BA0 is the battery attached to my laptop.

On executing the following command, complete information related to the battery is returned.

Since I am interested in only the battery remaining percentage, I will GREP the output. So the command would like this.

and here I get the output that I needed, directly from the terminal!

 

By | 2017-04-13T21:59:06+00:00 April 16th, 2017|Linux, operating systems|0 Comments

Leave A Comment