Power

How to Monitor and Optimize Power Usage on Linux

With more portable hardware on a rise, battery optimization can be a challenge for many users. After all, it’s the battery of your laptop and hand-held devices that has granted them the status of being called “portable”. Unfortunately, the battery use on Linux is particularly high as compared to most operating systems. One main reason behind this unusual power drainage is that hardware vendors do not provide the necessary documentation for Linux kernel developers to create power-optimized relevant drivers. This is because Linux captures just 2% of the market share in desktop technology. Therefore, as Linux users, we have to be especially concerned about monitoring power use on our systems and also come up with ways to optimize battery/power usage.This article lists some ways to monitor and optimize power usage on a Debian 10 Buster system. However, most procedures can be replicated on almost all Linux distros.

Monitoring Detailed Power Usage through the UI

There is no better tool available to monitor power usage on Linux than Gnome’s own Power Statistics tool. If you feel that any of your programs is using a significant amount of power or you are facing laptop battery issues, you can make use of this program. This utility is available in the Debian Stable Main repository and can be installed both through the Debian Software Manager(GUI) and the command line.

Installing Gnome Power Statistics Tool

If you want to use the Debian command line to install the tool, first open the Terminal through the Application Launcher search as follows:

In the Terminal, run the following two commands as sudo to install the Power Statistics tool:

$ sudo apt-get update
$ sudo apt-get install gnome-power-manager

Alternatively, for installing this software through the UI, please open the Debian Software Manager through the Activities panel/Dock. Then search for Gnome Power Statistics and install the one developed by GNOME.

Viewing Power Statistics

Launch the Power Statistics tool through the Application Launcher search as follows:

As you open the tool, you will be able to view the AC adapter details as follows:

To view the laptop battery information, click on the Laptop battery option:

The other views on this tab such as History and Statistics also provide graphical information about battery usage, its health, and capability.

Monitoring Detailed Power Usage Report through the Command Line

Here are a few ways through which you can monitor power usage and view battery report through the Linux command line.

1. With the upower utility, you can monitor activity from the power daemon as follows:

$ upower -monitor-detail

2. The acpi utility displays battery status and thermal information by fetching it from the /proc and /sys files. Here is how you can install it on your system:

$ sudo apt-get install acpi

You have the following options to view power-related information, through acpi:

3. If you want to monitor the status of your battery, you can install the Batstat utility by running the following commands:

$ git clone https://github.com/Juve45/batstat.git
$ cd batstat/bin/
$ sudo cp batstat /usr/local/bin/
$ sudo chmod +x /usr/local/bin/batstat

Then, run the batstat command to continuously monitor the battery status report:

$ batstat

Using Less Power on a Linux system

Here are a few tips through which you can ensure optimized power usage on your Linux system.

Method 1: Limiting Screen Brightness

A high brightness level takes quite a good tool on your power usage, be it AC or battery. If you adjust the brightness level for your screen to the lowest possible value, you will see a remarkable difference in the power used by your system. On Debian and Ubuntu, you will see Screen Brightness as the first adjustable setting you can make under Power Saving in your system settings.

Other things that will help are dimming the screen when inactive, switching off WiFi and Bluetooth if possible, and switching to a blank screen on x minutes of inactivity.

Method 2: Limiting USB devices

USB devices do not come with a power source of their own. The more the number of USB devices attached to your system, the more they leech on your system’s power source. Keep your USB devices to a minimum if you want to optimize your power usage/battery life.

Methos 3: Enabling TLP

TLP is an open-source and feature-rich facility that is used for power optimization on Linux systems. You can use its CLI or the GUI depending on your ease of use. When you enable TLP on your system, it optimizes power usage, all according to your operating system and the underlying machine. Here is how you can install it through the command line:

$ sudo apt-get install tlp

Once done, you can start TLP through the following command

$ sudo tlp start

In order to view system and power statistics through TLP, run the following command:

$ sudo tlp-stat -s

Method 4: Disabling Screensavers

Screensavers and screensaver software cost a lot of power on your system, especially if you are running the ones with heavy graphics. We suggest getting rid of any such extra software and also disabling the default screensaver application by running the following command:

$ xset s off

This will, however, set the screensaver off for the current login session. To disable the screensaver for good, open the .xsession file through the following command:

$ sudo nano $HOME/.xsession

Then, add the following line and save the file:

xset s off

Restart your system for the change to take effect.

Method 5: Using Lightweight Software

With the powertop utility, you can gauge which software is causing a burden on your power usage. You can install the utility through the following command:

$ sudo apt install powertop

Once you know about the heavy elephants on your system, you can get rid of them if they are causing more burden than ease.

This was all you needed to know about monitoring and managing power on your Linux system. This will be especially useful if you are running your system on a battery instead of AC.

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.