on_ac_power command not found

In this troubleshooting guide we learn how to fix on_ac_power command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

on_ac_power: command not found

or when using sudo you get the following error message

sudo: on_ac_power: command not found

Solutions to on_ac_power: command not found

How To Fix on_ac_power: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu on_ac_power is provided by powermgmt-base package.

powermgmt-base is:

This package ships “on_ac_power” which lets you determine whether the system is powered from battery or an abundant supply. It’s recommended to use this tool over a simple sysfs check, ConditionACPower or other ad-hoc methods which notoriously fail to account for unobvious quirks, both old and new.

To fix this problem, we can install more using the command below.

sudo apt-get -y install powermgmt-base

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install powermgmt-base.

sudo apt -y install powermgmt-base

Or if you have aptitude installed you can use the following command.

sudo aptitude install powermgmt-base

Summary

In this tutorial we learn how to fix on_ac_power command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.